Sign in to follow this  
Followers 0
Slvrngrn

BUTTON ISSUES

5 posts in this topic

OK, super-n00b here...

The code I have below is supposed to monitor my GUI. Obviously shut down the program if the GUI is exited, but I also want it to verify that a combobox selection has been made prior to moving on from the GUI. When I run it though I repeatedly get the MsgBox telling you to pick a crop. As soon as you close one box another pops up instantly. I tried $Button = 0 and $Button = False in the hopes that that would reset the button to the "unpressed" state. Is there a way to accomplish this so that once the MsgBox is closed the GUI will be "refreshed"? Or am I going about this completely wrong?

Thanks for your help and patience...

While $a = 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                $CropF = GUICtrlRead($Crop)
                If $CropF = "Select a crop..." Then
                    MsgBox(0, "Pick a crop", "You must select a crop to harvest.")
                    $a = 1
                    $Button1 = False
                Else
                    $a = $a - 1
                EndIf
        EndSwitch
    WEnd

Share this post


Link to post
Share on other sites



First of all, does this work better ? (as a first step)

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button1
                $CropF = GUICtrlRead($Crop)
                If $CropF = "Select a crop..." Then
                    MsgBox(0, "Pick a crop", "You must select a crop to harvest.")
                EndIf
        EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Yes, much cleaner. My trial and error has made a bit of mess... :D

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Now you can put your code inside a Else, after the If/Then. Right ?

If oyu want to get rid of the GUI, take a look at GUIDelete, although I've never used it :D

Edited by Inverted

Share this post


Link to post
Share on other sites

I actually took a much different approach from what I was doing... all because of GUIDelete. That worked like a champ!

Thanks a million!!!

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