YoseMite Posted May 28, 2005 Posted May 28, 2005 Hi, I will make a simple application with 2 buttons... The buttons work, but I can't close my application. My code: #include <GuiConstants.au3> Opt("GUIOnEventMode",1) ; make window......... ;buttons $start = GuiCtrlCreateButton("Start", 150, 110, 100, 40) GUICtrlSetOnEvent($start,"onstart") $stop = GuiCtrlCreateButton("Stop", 300, 110, 100, 40) GUICtrlSetOnEvent($stop,"onstop") ;FUNCTION for Button Func onstart() MsgBox(0,"Hi", "You click on START") EndFunc ;more ..... ;close application GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEnd Sorry for my bad language, I'm from Belgium.
Developers Jos Posted May 28, 2005 Developers Posted May 28, 2005 Hi,I will make a simple application with 2 buttons...The buttons work, but I can't close my application.My code:#include <GuiConstants.au3> Opt("GUIOnEventMode",1) ; make window......... ;buttons $start = GuiCtrlCreateButton("Start", 150, 110, 100, 40) GUICtrlSetOnEvent($start,"onstart") $stop = GuiCtrlCreateButton("Stop", 300, 110, 100, 40) GUICtrlSetOnEvent($stop,"onstop") ;FUNCTION for Button Func onstart() MsgBox(0,"Hi", "You click on START") EndFunc ;more ..... ;close application GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEndSorry for my bad language, I'm from Belgium.<{POST_SNAPBACK}>Have a look at the example in the Helpfile for GUICtrlSetOnEvent(). It shows how to detect the close window event. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
YoseMite Posted May 28, 2005 Author Posted May 28, 2005 I have view de helpfile, and have something chance, but it still don't close...
Developers Jos Posted May 28, 2005 Developers Posted May 28, 2005 I have view de helpfile, and have something chance, but it still don't close... <{POST_SNAPBACK}>how do you want to close ?With the stop button or with the X at the right top ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
FuryCell Posted May 28, 2005 Posted May 28, 2005 (edited) Hi,I will make a simple application with 2 buttons...The buttons work, but I can't close my application.My code:#include <GuiConstants.au3> Opt("GUIOnEventMode",1) ; make window......... ;buttons $start = GuiCtrlCreateButton("Start", 150, 110, 100, 40) GUICtrlSetOnEvent($start,"onstart") $stop = GuiCtrlCreateButton("Stop", 300, 110, 100, 40) GUICtrlSetOnEvent($stop,"onstop") ;FUNCTION for Button Func onstart() MsgBox(0,"Hi", "You click on START") EndFunc ;more ..... ;close application GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEndSorry for my bad language, I'm from Belgium.<{POST_SNAPBACK}>OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.so why not use this instead of While GuiGetMsg() <> $GUI_EVENT_CLOSE?GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") Func Quit () Exit EndFunc Edited May 28, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
YoseMite Posted May 28, 2005 Author Posted May 28, 2005 The program works now great! Thanks for your comments.
FuryCell Posted May 28, 2005 Posted May 28, 2005 The program works now great! Thanks for your comments.<{POST_SNAPBACK}>No Problem HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
YoseMite Posted June 10, 2005 Author Posted June 10, 2005 OMG! My pc is total crasht, and i haven't make a backup of my au3 files. I start my project, but de application doesn't close.Can someone please help my for the second time? My code:#include <GuiConstants.au3> Opt("GUIOnEventMode", 1) ;make form GuiCreate("program",600, 400) ;make buttons $start = GuiCtrlCreateButton("Start", 150, 110, 100, 40) GUICtrlSetOnEvent($start,"onstart") $stop = GuiCtrlCreateButton("Stop", 180, 110, 100, 40) GUICtrlSetOnEvent($stop,"onstop") ;functions -> buttons Func onstart() MsgBox(0,"Hi", "You click on START") EndFunc Func onstop() MsgBox(0,"Hi", "You click on STOP") EndFunc GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") Func Quit () Exit EndFuncI doesn't close.(The 'X' botton')Sorry people...
YoseMite Posted June 10, 2005 Author Posted June 10, 2005 This is very important for my... I have this topic view more than 10 times, but I don't get what I do wrong.
Developers Jos Posted June 11, 2005 Developers Posted June 11, 2005 This is very important for my...I have this topic view more than 10 times, but I don't get what I do wrong. <{POST_SNAPBACK}>You could have done what i answered previously in this very same threath here's an example:expandcollapse popup#include <GuiConstants.au3> opt("GUIOnEventMode", 1) ;make form GUICreate("program", 600, 400) GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents") GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents") ;make buttons $start = GUICtrlCreateButton("Start", 150, 110, 100, 40) GUICtrlSetOnEvent($start, "onstart") $stop = GUICtrlCreateButton("Stop", 180, 110, 100, 40) GUICtrlSetOnEvent($stop, "onstop") GUISetState(@SW_SHOW) ; Just idle around While 1 Sleep(10) Wend ;functions -> buttons Func onstart() MsgBox(0, "Hi", "You click on START") EndFunc ;==>onstart Func onstop() MsgBox(0, "Hi", "You click on STOP") EndFunc ;==>onstop GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") Func Quit() Exit EndFunc ;==>Quit Func SpecialEvents() Select Case @GUI_CtrlId = $GUI_EVENT_CLOSE MsgBox(0, "Close Pressed", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Exit Case @GUI_CtrlId = $GUI_EVENT_MINIMIZE MsgBox(0, "Window Minimized", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) Case @GUI_CtrlId = $GUI_EVENT_RESTORE MsgBox(0, "Window Restored", "ID=" & @GUI_CtrlId & " WinHandle=" & @GUI_WinHandle) EndSelect EndFunc ;==>SpecialEvents SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
MHz Posted June 11, 2005 Posted June 11, 2005 #include <GuiConstants.au3> Opt("GUIOnEventMode", 1) ;make form GuiCreate("program",600, 400) ;make buttons $start = GuiCtrlCreateButton("Start", 150, 110, 100, 40) GUICtrlSetOnEvent($start,"onstart") $stop = GuiCtrlCreateButton("Stop", 180, 110, 100, 40) GUICtrlSetOnEvent($stop,"onstop") ;functions -> buttons Func onstart() MsgBox(0,"Hi", "You click on START") EndFunc Func onstop() MsgBox(0,"Hi", "You click on STOP") EndFunc GUISetOnEvent($GUI_EVENT_CLOSE, "Quit") Func Quit () Exit EndFuncI doesn't close.(The 'X' botton')Sorry people... <{POST_SNAPBACK}>I am more surprised if you see the gui, yet unable to close it.As in the sample that JdeB shows; Just idle around While 1 Sleep(10) WendThis keeps the script alive. Something you are missing.GUISetState(@SW_SHOW)Another important thing missing. You will not see the Gui without it.Helpfile is full of good information. You need to look closer, at the examples.
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