Jump to content

GUI Acting wierd


MrTieDye
 Share

Recommended Posts

When I click on the Next Button, nothing happens. If I hit enter, it will click the button and execute the code for the button being pressed. Any suggestions?

$mainGui = GUICreate ( "Configuration", 500,250,-1,-1,-1,-1)
     
                    ;some labels
                     $label1 = GUICtrlCreateLabel("Welcome to the configuration utility", 50, 20,400,400)
                     GUICtrlSetFont($label1, "",1000)
                     
                    ;next and cancel buttons. No back yet because this is the first page
                     $nextbutton1 = GUICtrlCreateButton("Next", 360, 200, 60)
                     $cancelbutton = GUICtrlCreateButton("Cancel", 420, 200, 60)
 
                    ;show the gui
                     GUISetState(@SW_SHOW)
                     
                    ;wait for messages
                     While 1
                         $msg = GUIGetMsg()
                         
                         Select 
                            ;next button is pressed
                             Case $msg = $nextbutton1
                                ;increase the current window by 1
                                 $currentWindow = $currentWindow+1
                                ;quit the message loop
                                 GUIDelete()
                             ExitLoop
                             
                            ;cancel button is pressed
                             Case $msg = $cancelbutton
                                 CancelGui()
                             
                            ;close button is pressed
                             Case $msg = $GUI_EVENT_CLOSE
                                 CancelGui()
                         EndSelect
                     WEnd
Link to comment
Share on other sites

Need more (all) code.

What is $currentWindow? Where is it defined?

$currentWindow is just an integer to keep track of which GUI window should be displayed. So if $currentWindow = 2 and you click next, then $currentWindow will be incremented to 3. You could really remove the line with $currentWindow and the code would still act the same. Also, the following might help. Sorry, I forgot to include it....

Func CancelGui()
   ;Make sure user wants to quit without saving changes to config file
     $cancelquestion = MsgBox(4, "Are you sure?","You have not finished the configuration process. All configuration data will be lost")
     
   ;if they want to quit anyway
     If $cancelquestion = 6 Then 
       ;delete the config file
        ;FileDelete($configDir)
       ;hide the gui
         GUISetState(@SW_HIDE)
       ;delete the gui
         GUIDelete()
       ;exit the program
         Exit
     EndIf
 EndFunc
Edited by MrTieDye
Link to comment
Share on other sites

Here is a complete program listing that should compile with no errors. But the next button still does not work.

#include <GUIConstants.au3>
                    
Func CancelGui()
  ;Make sure user wants to quit without saving changes to config file
     $cancelquestion = MsgBox(4, "Are you sure?","You have not finished the configuration process. All configuration data will be lost")
    
  ;if they want to quit anyway
     If $cancelquestion = 6 Then
      ;delete the config file
       ;FileDelete($configDir)
      ;hide the gui
         GUISetState(@SW_HIDE)
      ;delete the gui
         GUIDelete()
      ;exit the program
         Exit
     EndIf
EndFunc
                    
$mainGui = GUICreate ( "Configuration", 500,250,-1,-1,-1,-1)
    
                   ;some labels
                     $label1 = GUICtrlCreateLabel("Welcome to the configuration utility", 50, 20,400,400)
                     GUICtrlSetFont($label1, "",1000)
                    
                   ;next and cancel buttons. No back yet because this is the first page
                     $nextbutton1 = GUICtrlCreateButton("Next", 360, 200, 60)
                     $cancelbutton = GUICtrlCreateButton("Cancel", 420, 200, 60)

                   ;show the gui
                     GUISetState(@SW_SHOW)
                    
                   ;wait for messages
                     While 1
                         $msg = GUIGetMsg()
                        
                         Select 
                           ;next button is pressed
                             Case $msg = $nextbutton1
                               ;increase the current window by 1
                                ;$currentWindow = $currentWindow+1
                               ;quit the message loop
                                 GUIDelete()
                             ExitLoop
                            
                           ;cancel button is pressed
                             Case $msg = $cancelbutton
                                 CancelGui()
                            
                           ;close button is pressed
                             Case $msg = $GUI_EVENT_CLOSE
                                 CancelGui()
                         EndSelect
                     WEnd
Link to comment
Share on other sites

Ok then... where are the other GUIs?

I didn't include them because they are not needed in order to get the problem I am having. I wanted to keep the code to a minimum so it is easier to read. In the post above, I posted a segment that I have put into AutoIT and still get the problem.

NOTE: If you run the code above, the next button should just close the gui. It does not if you click on it, but it will close if you hit enter.

Edited by MrTieDye
Link to comment
Share on other sites

Your label is hindering the "next" button... it's covering the button.

Make the label smaller.

Edit: sorry for the confusion. :)

Thanks so much. I have been banging my head on my desk for about 6 hours trying to figure that one out. What an obvious answer! Thanks again!
Link to comment
Share on other sites

Thanks so much. I have been banging my head on my desk for about 6 hours trying to figure that one out. What an obvious answer! Thanks again!

Tip:

When writing a GUI with Labels use the following technique when you are setting it up

$GUI = GUICreate("My GUI")
$Lbl_1 = GUICtrlCreateLabel("My first label", 10, 10, 160,20)
GUICtrlSetBKColor(-1, 0xFF0000)
$Lbl_2 = GUICtrlCreateLabel("My second label", 10, 10, 240,20)
GUICtrlSetBKColor(-1, 0x0000FF)
GUISetState()
While 1
 If GUIGetMsg() = -3 then Exit
Wend

That allows you to see the size and positioning of the labels. Remove the GUISetBKColor(0 lines when you have it right.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Tip:

When writing a GUI with Labels use the following technique when you are setting it up

$GUI = GUICreate("My GUI")
 $Lbl_1 = GUICtrlCreateLabel("My first label", 10, 10, 160,20)
 GUICtrlSetBKColor(-1, 0xFF0000)
 $Lbl_2 = GUICtrlCreateLabel("My second label", 10, 10, 240,20)
 GUICtrlSetBKColor(-1, 0x0000FF)
 GUISetState()
 While 1
  If GUIGetMsg() = -3 then Exit
 Wend

That allows you to see the size and positioning of the labels. Remove the GUISetBKColor(0 lines when you have it right.

Thanks for the info. I will most certainly use that in the future!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...