Jump to content
Sign in to follow this  

Need help on how to exit nested loop on GUI event

Recommended Posts

Does anyone have any suggestions as to what is wrong with this code? I tried several different ways to exit the second loop when I push stop on the GUI. All have failed. :D

Func _alertClient()
$frmAlertClient = GUICreate("Alert Client", 187, 54, 347, 280)
$btnStart = GUICtrlCreateButton("&Start", 8, 16, 75, 25, $BS_DEFPUSHBUTTON)
$btnStop = GUICtrlCreateButton("S&top", 104, 16, 75, 25)
    While 1
        $msg = GuiGetMsg()
        Case $msg = $GUI_EVENT_CLOSE
            GUISetState(@SW_Hide, $frmAlertClient)
        Case $msg = $btnStart
            While 1                                              ;=========endless loop starts here
                $msg = GuiGetMsg() 
                If $msg = $btnStop Then ExitLoop
                _Talk("Could the owner of this computer please return.")
            MsgBox(64, "Alert Stopped", "Client alert has been stopped.")
        Case Else

Share this post

Link to post
Share on other sites

GUIGetMsg is only checking every 4 seconds because of the sleeps. Remove the sleeps and try an alternate method using TimerInit() or something.

Share this post

Link to post
Share on other sites

Thanks a lot. Worked like a charm.

Just a suggestion:

There is one problem with your two loops. After you've pressed the start button, you cannot close the application until you press the stop button, as the GUI_EVENT_CLOSE message does not get processed in your inner loop. Maybe that's intentional, maybe not. You could set a variable after the start button was pressed. and then check that variable in your "outer" while loop, when the stop button gets pressed.



__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...