Sign in to follow this  
Followers 0
NerdFencer

Advanced Message Box UDF Lib

2 posts in this topic

#1 ·  Posted (edited)

This is a Message Box UDF Lib that can be used as a replacement for MsgBox when you don't want it to halt program execution

Functions

_MessageBox_Create

_MessageBox_Destroy

_MessageBox_SetButtonText

_MessageBox_SetButtonTip

_MessageBox_SetTimeout

_MessageBox_SetWindowIcon

_MessageBox_Update

Constants are also included for almost all return values and flags

Instructions for Basic Usage

Include the file and use _MessageBox_Create just like you would use MsgBox

The value that it returns is the handle to the message (not a valid handle, just an internal index for the Message Box Construct)

When processing the input from your GUI, call _MessageBox_Update(The handle returned from _MessageBox_Create, the return value from GUIGetMsg)

this will be default return:

  • -2 if the icon is clicked (box will not be destroyed, only present on some boxes)
  • -1 if the timeout is reached
  • 0 if nothing was updated
  • 1 if the first button was pressed
  • 2 if the seccond button was pressed
  • 3 if the third button was pressed
If you want to have the default MsgBox return values from this , call it with the following parameters

_MessageBox_Update(The handle returned from _MessageBox_Create, the return value from GUIGetMsg, True)

Warning

Not all of the more advanced flags from MsgBox are implemented as of yet, use of unsupported flags will make the window look glitchy, but will not do any harm. This will(should) only happen for Modality related flags.

I have not yet found where the Icons are stored for the parameters that add icons, so there are temporary replacements instead. These should suffice, but will not look as good. (if you know where they are or happen to find them, please tell me :D )

This has only been tested on Windows XP, so some icons may not be what is expected, and some sounds may not play for other versions of windows (please tell me if this happens)

MessageBox.au3

Edited by NerdFencer

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <WinAPI.au3>
Global Const $IDI_APPLICATION = 32512
Global Const $IDI_HAND = 32513
Global Const $IDI_QUESTION = 32514
Global Const $IDI_EXCLAMATION = 32515
Global Const $IDI_ASTERISK = 32516
Global Const $IDI_WINLOGO = 32517
Global $aIcons[6] = [$IDI_APPLICATION, $IDI_HAND, $IDI_QUESTION, $IDI_EXCLAMATION, $IDI_ASTERISK, $IDI_WINLOGO], $i, $aResult
Global $hGUI = GUICreate("Icons", 280, 40)
GUISetState()
Global $hDC = _WinAPI_GetDC($hGUI)
For $i = 0 To 5
    $aResult = DllCall("user32.dll", "hwnd", "LoadIcon", "ptr", 0, "long", $aIcons[$i])
    _WinAPI_DrawIconEx($hDC, $i * 48 + 4, 4, $aResult[0], 32, 32)
Next
While GUIGetMsg() <> -3
WEnd
Exit

Not sure why the $IDI_WINLOGO shows the same as $IDI_APPLICATION on my system but perhaps it's a Vista thing ...

Edited by WideBoyDixon

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0