Jump to content
Sign in to follow this  
wi1d

Need help on how to exit nested loop on GUI event

Recommended Posts

wi1d

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)
GUISetState(@SW_SHOW)
    While 1
        $msg = GuiGetMsg()
        Select
        Case $msg = $GUI_EVENT_CLOSE
            GUISetState(@SW_Hide, $frmAlertClient)
            ExitLoop
        Case $msg = $btnStart
            While 1                                              ;=========endless loop starts here
                $msg = GuiGetMsg() 
                If $msg = $btnStop Then ExitLoop
                _Talk("Attention")
                sleep(1000)
                _Talk("Could the owner of this computer please return.")
                sleep(3000)
            WEnd
            MsgBox(64, "Alert Stopped", "Client alert has been stopped.")
        Case Else
        ;;;;;;;
        EndSelect
    WEnd
EndFunc

Share this post


Link to post
Share on other sites
Knight

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
wi1d

Thanks a lot. Worked like a charm.

Edited by wi1d

Share this post


Link to post
Share on other sites
/dev/null

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.

Cheers

Kurt


__________________________________________________________(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  

×