Jump to content
Sign in to follow this  
NELyon

MessageBox Constants

Recommended Posts

NELyon

I have converted the MsgBox flags from the help file (Well, Actually I got them from a VBScript website) and converted them into an include file so you don't have to memorize the numerical values.

It has all of the standard MsgBox flags, and one that I found rather interesting: a flag which has... 7 Buttons! Yes, No, Cancel, Ok, Abort, Retry, and Ignore!

Here is the code:

CODE

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.0

Author: KentonBomb

Script Function:

Constants for MsgBox() Function

Notes:

Converted from the VBScript flags found at http://www.devguru.com/technologies/vbscri.../msgboxcon.html and numerous other places on the net

Although I could have easily converted it from the helpfile...

#ce ----------------------------------------------------------------------------

;//MessageBox Button Flags\\

Global Const $VBOKOnly = 0 ;Show OK button (Default for MsgBox'es, Hence it equals 0. Added for good measure)

Global Const $VBOKCancel = 1;Show OK and cancel buttons

Global Const $VBAbortRetryIgnore = 2;Show abort, retry, ignore buttons

Global Const $VBYesNoCancel= 3;Show yes, no cancel buttons

Global Const $VBYesNo= 4;Show yes, no buttons

Global Const $VBRetryCancel = 5;Show retry, cancel buttons

;//MessageBox "Icon" Flags\\

Global Const $VBCritical = 16;Show critical message icon

Global Const $VBQuestion = 32;Show warning query button

Global Const $VBExclaimation = 48;Show warning message icon

Global Const $VBInformation = 64;Show information message icon

;//MessageBox Default Icon Flags\\

Global Const $VBDefaultButton1 = 0;First button is default (This is default for MsgBox'es, Hence it equals 0. Added for good measure)

Global Const $VBDefaultButton2 = 256;Second button is default

Global Const $VBDefaultButton3 = 512;Third button is default

Global Const $VBDefaultButton4 = 768;Fourth button is default

;//MessageBox Return Values\\

Global Const $VBOK = 1;OK Button selected

Global Const $VBCancel = 2;Cancel button selected

Global Const $VBAbort = 3;Abort button selected

Global Const $VBRetry = 4;Retry button selected

Global Const $VBIgnore = 5;Ignore button selected

Global Const $VBYes = 6 ;Yes button selected

Global Const $VBNo = 7;No button selected

;//FunStuff\\

Global Const $VBYesNoOkCancelAbortRetryIgnore = 6

And an example:

#include "MessageBoxConstants.au3"
Switch MsgBox($VBYesNoOkCancelAbortRetryIgnore+$VBCritical+$VBDefaultButton3, "Whoa", "What to do?")
    Case $VBAbort
            MsgBox($VBOkOnly, "You pressed...", "Abort! How cool for you!")
    Case $VBRetry
            MsgBox($VBOkOnly, "You pressed...", "Retry! How cool for you!")
    Case $VBIgnore
            MsgBox($VBOkOnly, "You pressed...", "Ignore! How cool for you!")
    Case $VBYes
            MsgBox($VBOkOnly, "You pressed...", "Yes! How cool for you!")
    Case $VBNo
            MsgBox($VBOkOnly, "You pressed...", "No! How cool for you!")
    Case $VBOk
            MsgBox($VBOkOnly, "You pressed...", "Ok! How cool for you!")
    Case $VBCancel
            MsgBox($VBOkOnly, "You pressed...", "Cancel! How cool for you!")
EndSwitch

The above makes a 7 buttoned message box with the "Critical" icon, with the 3rd button (Ok) Being the default. Makes it easier if you ask me.

Comments/Questions appreciated!

Share this post


Link to post
Share on other sites
zackrspv

I have converted the MsgBox flags from the help file (Well, Actually I got them from a VBScript website) and converted them into an include file so you don't have to memorize the numerical values.

It has all of the standard MsgBox flags, and one that I found rather interesting: a flag which has... 7 Buttons! Yes, No, Cancel, Ok, Abort, Retry, and Ignore!

Here is the code:

CODE

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.0

Author: KentonBomb

Script Function:

Constants for MsgBox() Function

Notes:

Converted from the VBScript flags found at http://www.devguru.com/technologies/vbscri.../msgboxcon.html and numerous other places on the net

Although I could have easily converted it from the helpfile...

#ce ----------------------------------------------------------------------------

;//MessageBox Button Flags\\

Global Const $VBOKOnly = 0 ;Show OK button (Default for MsgBox'es, Hence it equals 0. Added for good measure)

Global Const $VBOKCancel = 1;Show OK and cancel buttons

Global Const $VBAbortRetryIgnore = 2;Show abort, retry, ignore buttons

Global Const $VBYesNoCancel= 3;Show yes, no cancel buttons

Global Const $VBYesNo= 4;Show yes, no buttons

Global Const $VBRetryCancel = 5;Show retry, cancel buttons

;//MessageBox "Icon" Flags\\

Global Const $VBCritical = 16;Show critical message icon

Global Const $VBQuestion = 32;Show warning query button

Global Const $VBExclaimation = 48;Show warning message icon

Global Const $VBInformation = 64;Show information message icon

;//MessageBox Default Icon Flags\\

Global Const $VBDefaultButton1 = 0;First button is default (This is default for MsgBox'es, Hence it equals 0. Added for good measure)

Global Const $VBDefaultButton2 = 256;Second button is default

Global Const $VBDefaultButton3 = 512;Third button is default

Global Const $VBDefaultButton4 = 768;Fourth button is default

;//MessageBox Return Values\\

Global Const $VBOK = 1;OK Button selected

Global Const $VBCancel = 2;Cancel button selected

Global Const $VBAbort = 3;Abort button selected

Global Const $VBRetry = 4;Retry button selected

Global Const $VBIgnore = 5;Ignore button selected

Global Const $VBYes = 6 ;Yes button selected

Global Const $VBNo = 7;No button selected

;//FunStuff\\

Global Const $VBYesNoOkCancelAbortRetryIgnore = 6

And an example:

#include "MessageBoxConstants.au3"
Switch MsgBox($VBYesNoOkCancelAbortRetryIgnore+$VBCritical+$VBDefaultButton3, "Whoa", "What to do?")
    Case $VBAbort
            MsgBox($VBOkOnly, "You pressed...", "Abort! How cool for you!")
    Case $VBRetry
            MsgBox($VBOkOnly, "You pressed...", "Retry! How cool for you!")
    Case $VBIgnore
            MsgBox($VBOkOnly, "You pressed...", "Ignore! How cool for you!")
    Case $VBYes
            MsgBox($VBOkOnly, "You pressed...", "Yes! How cool for you!")
    Case $VBNo
            MsgBox($VBOkOnly, "You pressed...", "No! How cool for you!")
    Case $VBOk
            MsgBox($VBOkOnly, "You pressed...", "Ok! How cool for you!")
    Case $VBCancel
            MsgBox($VBOkOnly, "You pressed...", "Cancel! How cool for you!")
EndSwitch

The above makes a 7 buttoned message box with the "Critical" icon, with the 3rd button (Ok) Being the default. Makes it easier if you ask me.

Comments/Questions appreciated!

Not bad, good addition imho.

MsgBox($VBOKOnly+$VBInformation, "test", "test")

Far easier to understand than just adding #'s together lol


-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites
NELyon

Not bad, good addition imho.

MsgBox($VBOKOnly+$VBInformation, "test", "test")

Far easier to understand than just adding #'s together lol

$VBOkOnly is default, so you could have written that line:

MsgBox($VBInformation, "Test", "Test")

Which would produce the same result :)

Share this post


Link to post
Share on other sites
MHz

Nice, VB constant variables.

Are you aware that AutoIt3 has included MsgBox constants since as long as I can remember? :)

#include <Constants.au3>

Switch MsgBox($MB_YESNO, 'Whoa', 'What to do?')
    Case $IDYES
        MsgBox(0, 'You pressed...', 'Yes! How cool for you!')
    Case $IDNO
        MsgBox(0, 'You pressed...', 'No! How cool for you!')
EndSwitch

Share this post


Link to post
Share on other sites
zackrspv

Nice, VB constant variables.

Are you aware that AutoIt3 has included MsgBox constants since as long as I can remember? :)

#include <Constants.au3>

Switch MsgBox($MB_YESNO, 'Whoa', 'What to do?')
    Case $IDYES
        MsgBox(0, 'You pressed...', 'Yes! How cool for you!')
    Case $IDNO
        MsgBox(0, 'You pressed...', 'No! How cool for you!')
EndSwitch
Y'all should add those constants the the helpfile for MSGBOX then. Because right now, it only shows the #'s, not the constants :)
  • Like 1

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites
ProgAndy

The above makes a 7 buttoned message box with the "Critical" icon, with the 3rd button (Ok) Being the default. Makes it easier if you ask me.

Doesn't work for me. ( XP MCE SP2, German)

I get

[Abbrechen] [Wiederholen] [Weiter]

[....Abort....] [.....Retry.....] [Continue]

with Return values:

-$VBCancel ----- 10 ------------11------

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
NELyon

Doesn't work for me. ( XP MCE SP2, German)

I get

[Abbrechen] [Wiederholen] [Weiter]

[....Abort....] [.....Retry.....] [Continue]

with Return values:

-$VBCancel ----- 10 ------------11------

Idk... Maybe it's different for non-English systems.

Here's how it looks on my system.

post-12929-1211389333_thumb.png

Share this post


Link to post
Share on other sites
-Ultima-

Idk... Maybe it's different for non-English systems.

Here's how it looks on my system.

post-12929-1211389333_thumb.png

That's a Wine bug then, as 0x6 is the value assigned to MB_CANCELTRYCONTINUE. Here's a slightly more complete version of the constants list I compiled recently as well:

; Return values
Global Const $IDTIMEOUT  = -1
Global Const $IDABORT    = 0x3
Global Const $IDCANCEL   = 0x2
Global Const $IDCONTINUE = 0xB
Global Const $IDIGNORE   = 0x5
Global Const $IDNO       = 0x7
Global Const $IDOK       = 0x1
Global Const $IDRETRY    = 0x4
Global Const $IDTRYAGAIN = 0xA
Global Const $IDYES      = 0x6

; Buttons
Global Const $MB_ABORTRETRYIGNORE  = 0x0002
Global Const $MB_CANCELTRYCONTINUE = 0x0006
Global Const $MB_HELP              = 0x4000
Global Const $MB_OK                = 0x0000
Global Const $MB_OKCANCEL          = 0x0001
Global Const $MB_RETRYCANCEL       = 0x0005
Global Const $MB_YESNO             = 0x0004
Global Const $MB_YESNOCANCEL       = 0x0003

; Icons
Global Const $MB_ICONASTERISK    = 0x40
Global Const $MB_ICONEXCLAMATION = 0x30
Global Const $MB_ICONHAND        = 0x10
Global Const $MB_ICONQUESTION    = 0x20
Global Const $MB_IConerror       = $MB_ICONHAND
Global Const $MB_ICONINFORMATION = $MB_ICONASTERISK
Global Const $MB_IConstop        = $MB_ICONHAND
Global Const $MB_ICONWARNING     = $MB_ICONEXCLAMATION

; Default buttons
Global Const $MB_DEFBUTTON1 = 0x000
Global Const $MB_DEFBUTTON2 = 0x100
Global Const $MB_DEFBUTTON3 = 0x200
Global Const $MB_DEFBUTTON4 = 0x300

; Modality
Global Const $MB_APPLMODAL   = 0x0000
Global Const $MB_SYSTEMMODAL = 0x1000
Global Const $MB_TASKMODAL   = 0x2000

; Miscellaneous
Global Const $MB_DEFAULT_DESKTOP_ONLY      = 0x00020000
Global Const $MB_RIGHT                     = 0x00080000
Global Const $MB_RTLREADING                = 0x00100000
Global Const $MB_SERVICE_NOTIFICATION      = 0x00200000
Global Const $MB_SETFOREGROUND             = 0x00010000
Global Const $MB_TOPMOST                   = 0x00040000
Global Const $MB_SERVICE_NOTIFICATION_NT3X = $MB_TOPMOST

It's interesting how you, AlmarM, and I all attempted to compile a list of messagebox constants around the same time (within a week of one another). Naturally, I didn't see this thread, though, as I wouldn't have bothered wasting the few minutes of my life hunting down the exact values had I seen this thread and found out that Constants.au3 already contained most of the constants (as MHz pointed out) xD

Edited by -Ultima-

[ WinINet.au3 | Array.au3 (Optimized) | _UnixTimeParse() ]

Share this post


Link to post
Share on other sites
NELyon

Hmm, Odd, Because I could swear that I remember this behavior even before I switched to Linux. Maybe I'm going Psycho Crazy.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.