Sign in to follow this  
Followers 0

MsgBox

38 posts in this topic

Posted

Hello there,

Case $hButton5
MsgBox (4,"Update", " Check for updates?")
if $hButton5 = 6 Then
gui3()
ElseIf  $hButton5 = 7 Then
Exit    ; what should i add here to make the MsgBox close if i chose 7 = No?
EndIf

How do i make the MsgBox close if i chose the answer 7 = no???

Share this post


Link to post
Share on other sites



Posted

ileandros,

You test the return value from the MsgBox, not the original button. The MsgBox exits automatically when you press one of its buttons: ;)

Case $hButton5
    ; Create MsgBox and wait for the user to click a button on the MsgBox
    If MsgBox(4, "Update", " Check for updates?") = 6 Then
        ; If the "Yes" button was pressed
        gui3()
    Else
        ; In all other cases
        Exit
    EndIf

All cler? :)

M23

Share this post


Link to post
Share on other sites

Posted

ileandros,

You test the return value from the MsgBox, not the original button. The MsgBox exits automatically when you press one of its buttons: ;)

Case $hButton5
    ; Create MsgBox and wait for the user to click a button on the MsgBox
    If MsgBox(4, "Update", " Check for updates?") = 6 Then
        ; If the "Yes" button was pressed
        gui3()
    Else
        ; In all other cases
        Exit
    EndIf

All cler? :)

M23

Nah this also gives the same action as the 6 =Yes :/

Share this post


Link to post
Share on other sites

Posted

ileandros,

Then post the working code you run that has the MsgBox remaining open after you press one if its buttons. :)

M23

Share this post


Link to post
Share on other sites

Posted

ileandros,

That is not "working code" - I mean a full script that can actually be run. :)

Make it easy for us to help you - then we all win. ;)

M23

Share this post


Link to post
Share on other sites

Posted

Ahhh yes i thought only the gui for the button :)

Here it is.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Global $hGUI2 = 9999, $hButton3 = 9999 ; Predeclare the variables with dummy values to prevent firing the Case statements

gui1()

Func gui1()

$hForm1 = GUICreate("", 674, 190, 195, 130) 
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE,295,35,330,110)
$hButton1 = GUICtrlCreateButton("", 295, 150, 50, 25)
$hButton3 = GUICtrlCreateButton("", 355, 150, 50, 25)
$hButton5 = GUICtrlCreateButton("?",660,1,15,20)
$hButton2 = GUICtrlCreateButton("", 40, 150, 80, 25)
$hButton4 = GUICtrlCreateButton("Exit", 545, 150, 80, 25)
$List1 = GUICtrlCreateList("", 40, 35, 201, 110)
GUICtrlSetData(-1,"")
$hGroup1 = GUICtrlCreateGroup("", 24, 16, 230, 170)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hGroup2 = GUICtrlCreateGroup("", 280, 16, 365, 170)
GUICtrlCreateGroup("", -99, -99, 1, 1)



GUISetState(@SW_SHOW)



    While 1
        $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array
        Switch $aMsg[1] ; check which GUI sent the message
            Case $hForm1
                Switch $aMsg[0] ; Now check for the messages for $hGUI1
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we exit <<<<<<<<<<<<<<<
                        ExitLoop




Case $hButton5
MsgBox (4,"Update", " Check for updates?")
if $hButton5 = 6 Then
gui3()
Elseif 
exit


EndIf
Case $hButton4
MsgBox(0,"Exit","Now exiting...")
Exit



                EndSwitch
            Case $hGUI2
                Switch $aMsg[0] ; Now check for the messages for $hGUI2
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we just delete the GUI <<<<<<<<<<<<<<<
                        GUIDelete($hGUI2)
                        GUICtrlSetState($hButton2, $GUI_ENABLE) 
                EndSwitch
        EndSwitch
    WEnd

EndFunc   ;==>gui1

Func gui2()

$hGUI2 = GUICreate("Youtube",800,600,200,50)
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE,10,10,780,580)
_IENavigate($oIE,"")
GUISetState(@SW_SHOW)

EndFunc 

Func gui3()

$hGUI2 = GUICreate("iRadio v1.0",1000,600,200,50)
$oIE = _IECreateEmbedded()
GUICtrlCreateObj($oIE,10,10,980,580)
_IENavigate($oIE,"http://www.google.gr/")
GUISetState(@SW_SHOW)

EndFunc

Share this post


Link to post
Share on other sites

Posted

You're not checking the return from the MsgBox, you're still using the controlID of $hButton5, which just so happens to be 6. You should also change the ElseIf back to an Else statement. Using Melba23's suggestion for the message box will fix this problem.

Share this post


Link to post
Share on other sites

Posted

I tried it but i didn't make it.... I posted the script above.

Please check it, try it and tell me if im doing sth wrong.

Share this post


Link to post
Share on other sites

Posted (edited)

You need to run au3check on your code as it contains errors.

As to you question:

If MsgBox(4, "Update", " Check for updates?") = 6 Then
       gui3()
      Else
       Exit
      EndIf
Edited by Jos

Share this post


Link to post
Share on other sites

Posted

You need to run au3check on your code as it contains errors.

As to you question:

If MsgBox(4, "Update", " Check for updates?") = 6 Then
       gui3()
      Else
       Exit
      EndIf

This doesnt work i already tried it... There are no errors.

The problem is that the

Else
gives the same resault as the

If MsgBox(4, "Update", " Check for updates?") = 6 Then
       gui3()
. It doesn't exit the MsgBox :/

Share this post


Link to post
Share on other sites

Posted

Well the If I posted is correct and works fine for me.

When I click Yes it will show the Google.gr page and when I click No it will exit the script since that is what Exit does.

Share this post


Link to post
Share on other sites

Posted

Well the If I posted is correct and works fine for me.

When I click Yes it will show the Google.gr page and when I click No it will exit the script since that is what Exit does.

I want the No to exit the MsgBox. I just don't know why but my script run it the same as the YES.

What the hell??? Is there another way to do it???? So i can avoid this??

Share this post


Link to post
Share on other sites

Posted (edited)

I want the No to exit the MsgBox. I just don't know why but my script run it the same as the YES.

What the hell??? Is there another way to do it???? So i can avoid this??

Any button you click on the MSGBOX will exit the MsgBox().

So What exactly do you want to happen when No is clicked and the MSGbox is gone? Just display the Main GUI or something else?

.. by the way... it works best when you do not loose your temper... at least with me...

Edited by Jos

Share this post


Link to post
Share on other sites

Posted (edited)

I think you are confusing the ideas of MsgBox with your GUI window. They are separate things. When you click any button on the MsgBox (or the timeout expires), the MsgBox automatically closes and returns a value indicating why it closed (which button was pushed, etc.); the MsgBox does not stick around after that, no matter which button you pushed. The GUI that you created can still stick around after the MsgBox disappears, but that is a different story.

As an experiment, build a simple script with just a message box with Yes, No, Cancel as the buttons. Put the value returned from the MsgBox into a variable. Present that value from a Ok only message box just after that.

Dim $nRetVal

$nRetVal = MsgBox(3+32, "MsgBox Test", "Please press a button.")
MsgBox(64, "MsgBox Test", "The returned number from the last MsgBox was " & $nRetVal & ".")

I like to close the GUI window before exiting with GuiDelete, but that appears to be just me.

Edited by Nutster

Share this post


Link to post
Share on other sites

Posted

Thanks Nutster,

I found what the prob was. Thank to ur help.

I just add this simple

$msgbox
thing and it seems to work fine finally

Case $hButton5
$msgbox = MsgBox (4,"Update", " Check for updates?")
if $msgbox = 6 Then
gui3()
EndIf

As simple as this. I dont know why but adding

$msgbox
solved my prob.

Thank u all for your help :)

Share this post


Link to post
Share on other sites

Posted

As BrewManNH said i was just using the controlID of $hButton5 and not the msgbox that was the prob.

Share this post


Link to post
Share on other sites

Posted

Thanks Nutster,

I found what the prob was. Thank to ur help.

I just add this simple

$msgbox
thing and it seems to work fine finally

Case $hButton5
$msgbox = MsgBox (4,"Update", " Check for updates?")
if $msgbox = 6 Then
gui3()
EndIf

As simple as this. I dont know why but adding

$msgbox
solved my prob.

Thank u all for your help :)

That is exactly the same a M23 provided, except the Exit

Case $hButton5
    ; Create MsgBox and wait for the user to click a button on the MsgBox
    If MsgBox(4, "Update", " Check for updates?") = 6 Then
        ; If the "Yes" button was pressed
        gui3()
    Else
        ; In all other cases
        Exit
    EndIf

Share this post


Link to post
Share on other sites

Posted

That is exactly the same a M23 provided, except the Exit

Nah dude. If u check it better u will find the difference.

That is what it makes it work fine :)

Share this post


Link to post
Share on other sites

Posted

Are you suggesting MsgBox Returns a different value when a variable is waiting to receive it?

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