adamb53 Posted June 7, 2013 Share Posted June 7, 2013 (edited) Hi all, What I am trying to do at the moment is I have a gui and in the gui is a button, when the button is pressed it should close the gui, I haven't been able to figure out why this isn't working but it does close the gui when the x is pushed or esc so that on event is working, am I missing something? The following code is where the button and on event is done expandcollapse popup; ===================================== ; ; The GUI Window Is Created Here ; ; Created By: Adam Blackburn ; ; ===================================== ; ; Includes #include <GUIConstantsEX.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIButton.au3> #include "Conditionals.au3" ; Enable onEvent Mode Opt("GUIOnEventMode", 1) ; GUI Windows Dimensions Global $GUIWidth = 600 Global $GUIHeight = 400 Global $newButton Func mainGUI() ; Creates the main GUI window $mainGUI = GUICreate("", $GUIWidth, $GUIHeight, Default, Default, BitOR($WS_CAPTION, $WS_MINIMIZEBOX, $WS_SYSMENU)) ; Creates the "Left Pane" in the GUI Window $leftPane = GUICtrlCreateGroup("", 0, 10, 400, 400) newButton() ; Creates the "Right Pane" in the GUI Window $rightPane = GUICtrlCreateGroup("", 400, 10, 200, 400) ; onEvents() has all setOnEvents [ex: For when a button is pushed) onEvents() ; Show the GUI GUISetState(@SW_SHOW) ; This is so the GUI stays Open While 1 Sleep(1000) WEnd EndFunc ;==>mainGUI Func newButton() $newButton = GUICtrlCreateButton("New Button", 10, 10, 100, 100) EndFunc ; All the events to do when an action is performed (button push) Func onEvents() ; Exits when the button is pushed GUISetOnEvent($newButton, "OnExit") ; Close the GUI when an exit action is performed (Clicking the 'X' or 'Close' Button) GUISetOnEvent($GUI_EVENT_CLOSE, "OnExit") EndFunc ;==>onEvents And this is where the "exit" event is. ; ===================================== ; ; All Conditionals are made here ; ; These are what to do "on event" ; ; Created By: Adam Blackburn ; ; ===================================== ; Func OnExit() Exit EndFunc ;==>OnExit Edited June 7, 2013 by adamb53 Link to comment Share on other sites More sharing options...
Solution FireFox Posted June 7, 2013 Solution Share Posted June 7, 2013 Hi, You are using the GUISetOnEvent function for a control, however this function is only to set an event on the GUI. Thus you need the GUICtrlSetOnEvent function, don't forget to take a look at the helpfile, it would have avoided this kind of mistake. Br, FireFox. adamb53 1 Link to comment Share on other sites More sharing options...
adamb53 Posted June 7, 2013 Author Share Posted June 7, 2013 I definitely feel like an idiot now as I have done this in the past which is why I was going crazy trying to figure it out. I usually try help files first but I completely forgot about the difference between setting to the gui and to gui ctrl Thanks for the quick response though Link to comment Share on other sites More sharing options...
FireFox Posted June 7, 2013 Share Posted June 7, 2013 You're welcome You can set the topic to answered thanks to the "Mark solved" button. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now