Novack Posted August 16, 2006 Share Posted August 16, 2006 Hi, I'm trying to create a program that can dynamically create a GUI based on a config file. For this, I need to create GUI code where when user clicks Next, the system reads the config for the next "page", and calls the same routine it used to draw the first "page" with the new parameters. This is why I cannot create a GUI with a flow of "First Window" -> "Second Window" -> etc.. since the scheme needs to scale to everywhere from 2 to several tens of dialogs. I use the onEvent GUI mode, and run into problems when switching from the initally drawn window to the second one. The UI stops responding completely, even things that worked fine on the first window (the same code is used to draw the second window, as I detailed above). A testing code with the same effect is below. Can somebody please tell me what I have done wrong here (or if I'm trying something impossible), and I'd be grateful for suggestions to alternative implementations for the same effect. As you can see if you execute the code, the cancel button that works fine when first run, stops working when Next is clicked once. I'm running v3.1.1.133 beta. Opt("GUIOnEventMode",1) _CreateTestWindow() Func _CreateTestWindow() Global $G_PageWindow = GUICreate("Test", 200, 100, -1, -1) $PageNext = GUICtrlCreateButton("&Next >", 20, 10, 60, 40) GUICtrlSetOnEvent($PageNext, "NextClick") $PageCancel = GUICtrlCreateButton("Cancel", 100, 10, 60, 40) GUICtrlSetOnEvent($PageCancel, "CancelClick") GUISetState(@SW_SHOW) While 1 Sleep(1000) WEnd EndFunc Func NextClick() GUIDelete($G_PageWindow) _CreateTestWindow() EndFunc Func CancelClick() Exit EndFunc Link to comment Share on other sites More sharing options...
Danny35d Posted August 16, 2006 Share Posted August 16, 2006 Can somebody please tell me what I have done wrong here (or if I'm trying something impossible)Yes it is possible, you almost had it. All you need to do is move the while statement out of the function. Opt("GUIOnEventMode",1) _CreateTestWindow() While 1 Sleep(1000) WEnd Func _CreateTestWindow() Global $G_PageWindow = GUICreate("Test", 200, 100, -1, -1) $PageNext = GUICtrlCreateButton("&Next >", 20, 10, 60, 40) GUICtrlSetOnEvent($PageNext, "NextClick") $PageCancel = GUICtrlCreateButton("Cancel", 100, 10, 60, 40) GUICtrlSetOnEvent($PageCancel, "CancelClick") GUISetState(@SW_SHOW) EndFunc Func NextClick() GUIDelete($G_PageWindow) _CreateTestWindow() EndFunc Func CancelClick() Exit EndFunc AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Novack Posted August 17, 2006 Author Share Posted August 17, 2006 Thanks for the help, now it works. 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