Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

[AHK_L] QMsgBox - customizable message box


  • Please log in to reply
No replies to this topic
Deo
  • Members
  • 199 posts
  • Last active: Jan 31 2014 03:19 PM
  • Joined: 16 May 2010
Hello!
It took me a few days to make an alternative to WinAPI msgbox which in some cases very handy, but mostly - not! :lol:

Here is what i created QMsgBox for, comparably to standard one:

[*:s45igqhp] It may have ANY number of buttons with ANY text on them
[*:s45igqhp] You may put ANY picture/icon beside standard ones
[*:s45igqhp] It may be shown up with first button just under your mouse cursor, not strictly centered on the screen
[*:s45igqhp] It have a few nice styles like window without caption or sysmenu
[*:s45igqhp] You can lock any number of guis with it, not only the one from you calling it
[*:s45igqhp] Object based - you can change parameters on the fly without recreating all the stuff
Ok, here is a few screenshots:
Posted Image

Requirement:
AHK_L Unicode x32/x64 ( i'm not sure about ANSI build )

Download (.zip)

If you pass just a string to QMsgBox constructor - it will be considered as "msg" parameter with all others set by default

[*:s45igqhp]QMsgBox.SetParams( params )
After creating the object, you can change any parameter by passing the same params object to the QMsgBox.SetParams() method or by changing it's fields with the same name as parameters, for example:

params := { "msg" : "HelloWorld"
                  ,"icon" : "shell32.dll:16" }

mb := new QMsgBox( params  )
mb.Show()

;one way to change parameter
params[ "title" ] := "this is now title"
mb.SetParams( params )
mb.Show()

;another way
mb.nocaption := 1
mb.Show()

the most significant part is the QMsgBox.Show() method
it's actually shows the box and, after dissmissing, returns text of the button which was pressed or blank string if box was closed
If it called from the Gui-related thread (which means A_Gui variable is defined ) and has "modal" paramter True - it will disable that gui and become owned by it
Is can also accept list of gui numbers separated with "|" which you want to disable while msgbox is shown, for example:

; guis 2,5,8 will be disabled while msgbox shown and, if modal = 1 and no A_Gui defined, the first ( 2 ) gui will become its owner
mb.Show( "2|5|8" )

[*:s45igqhp]QMsgBoxF function
There is also QMsgBoxF function available for faster box creating/showinf:
QMsgBoxF( title = "", msg = "", sBtns = "OK", icon = "", centered = True, modal = False )
which is self explanable i hope :)