Hyflex

Unable to the result of MsgBox working...

4 posts in this topic

#1 ·  Posted

I've tried to get the MsgBox's working for quite a while and searched the forums, stackoverflow and google but can't find how to resolve this. I've tried to create a messagebox in Scite but that too has the same issue where none of the results work except for the else... which is pretty useless.

See some example code below:

#include <MsgBoxConstants.au3>
;#include <GuiConstantsEx.au3>
$Status = "Test"
$Message = "Beep Beep"

If Not IsDeclared("UpdateResult") Then Local $UpdateResult
$UpdateResult = MsgBox($MB_OKCANCEL & $MB_ICONWARNING, $Status & " Available", "There is a " & $Status & "." & @CRLF & @CRLF & "Press OK to " & $Status & @CRLF & @CRLF & $Message)

Select
    Case $UpdateResult = 1 ;OK
        ConsoleWrite("Switch 1" & @CRLF)
    Case $UpdateResult = 2
        ConsoleWrite("Switch 2" & @CRLF)
EndSelect

If $UpdateResult = 1 Then
    ConsoleWrite("If 1" & @CRLF)
ElseIf $UpdateResult = 2 Then
    ConsoleWrite("ElseIf" & @CRLF)
Else
    ConsoleWrite("Else" & @CRLF) ; Only one that fires....
EndIf

How do I get OK button & cancel button to do things...?

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Not &, but +

$UpdateResult = MsgBox($MB_OKCANCEL + $MB_ICONWARNING, ...

 

Edited by InnI

Share this post


Link to post
Share on other sites

#3 ·  Posted

For example, to specify a SYSTEMMODAL box with the YES/NO buttons the flag value would be 4096+4 (or 4100) If using hexadecimal flags, that would be 0x1000+0x4 (or 0x1004).

Share this post


Link to post
Share on other sites

#4 ·  Posted

Like this?

#include <MsgBoxConstants.au3>
;#include <GuiConstantsEx.au3>
$Status = "Test"
$Message = "Beep Beep"

If Not IsDeclared("UpdateResult") Then Local $UpdateResult
$UpdateResult = MsgBox($MB_OKCANCEL + $MB_ICONWARNING, $Status & " Available", "There is a " & $Status & "." & @CRLF & @CRLF & "Press OK to " & $Status & @CRLF & @CRLF & $Message)

Select
    Case $UpdateResult = 1 ;OK
        ConsoleWrite("Switch 1" & @CRLF)
        ConsoleWrite("Select --- the first time I had to do something " & $UpdateResult & @CRLF )
    Case $UpdateResult = 2
        ConsoleWrite("Switch 2" & @CRLF)
EndSelect

If $UpdateResult = 1 Then
    ConsoleWrite("If 1" & @CRLF)
    ConsoleWrite("Select --- the second time I had to do something " & $UpdateResult & @CRLF )
ElseIf $UpdateResult = 2 Then
    ConsoleWrite("ElseIf" & @CRLF)
Else
    ConsoleWrite("Else" & @CRLF) ; Only one that fires....
EndIf

Like @InnI wrote, your MsgBox flags were wrongly formatted...

Skysnake


Skysnake

Why is the snake in the sky?

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