Bokkie Posted March 2, 2006 Share Posted March 2, 2006 (edited) I'm prototyping a sample form using the GUI controls. I created a form and added a button. In the message loop I want to create another form. Then when that form is closed control reverts back to the original. The second form is displayed ok but when I close it, both it and the parent form are closed. Are sub-forms allowed or am I failing to do something properly. Here is the 'dirty' code I've got so far: #include <GUIConstants.au3> GUICreate("Test Form", 270, 180, -1, -1) $buttonLeft = 5 $buttonTop = 5 $buttonWidth = 100 $buttonHeight = 25 $button1 = GUICtrlCreateButton("Install A", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight) $buttonTop = $buttonTop + $buttonHeight + 5 $button2 = GUICtrlCreateButton("Install B", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight) $label1 = GUICtrlCreateLabel("", 185, 50, 70, 25, 0x1000) $label2 = GUICtrlCreateLabel("", 185, 25, 70, 25, 0x1000) GuiSetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button1 GUICtrlSetData($label2, "1") GUICtrlSetData($label1, "1") GUICreate("Test Form", 270, 180, -1, -1) GuiSetState() ; Not sure what to do at this point??????? Case $msg = $button2 $results = "2" GUICtrlSetData($label2, $results) GUICtrlSetData($label1, "2") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Any ideas what I need to do? Edited March 2, 2006 by Peter Hamilton-Scott Link to comment Share on other sites More sharing options...
seandisanti Posted March 2, 2006 Share Posted March 2, 2006 I'm prototyping a sample form using the GUI controls. I created a form and added a button. In the message loop I want to create another form. Then when that form is closed control reverts back to the original.The second form is displayed ok but when I close it, both it and the parent form are closed. Are sub-forms allowed or am I failing to do something properly. Here is the 'dirty' code I've got so far:#include <GUIConstants.au3>GUICreate("Test Form", 270, 180, -1, -1)$buttonLeft = 5$buttonTop = 5$buttonWidth = 100$buttonHeight = 25$button1 = GUICtrlCreateButton("Install A", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)$buttonTop = $buttonTop + $buttonHeight + 5$button2 = GUICtrlCreateButton("Install B", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight)$label1 = GUICtrlCreateLabel("", 185, 50, 70, 25, 0x1000)$label2 = GUICtrlCreateLabel("", 185, 25, 70, 25, 0x1000)GuiSetState()While 1 $msg = GUIGetMsg() Select Case $msg = $button1 GUICtrlSetData($label2, "1") GUICtrlSetData($label1, "1") GUICreate("Test Form", 270, 180, -1, -1) GuiSetState() ; Not sure what to do at this point??????? Case $msg = $button2 $results = "2" GUICtrlSetData($label2, $results) GUICtrlSetData($label1, "2") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoopWendAny ideas what I need to do?you should assign variables to your GUICreate()'s. that way you can reference each of the windows specifically. also on $GUI_EVENT_CLOSE event, you can check which window is supposed to close, and kill that window. Link to comment Share on other sites More sharing options...
GaryFrost Posted March 2, 2006 Share Posted March 2, 2006 expandcollapse popup#include <GUIConstants.au3> $gui1 = GUICreate ("Test Form", 270, 180, -1, -1) $buttonLeft = 5 $buttonTop = 5 $buttonWidth = 100 $buttonHeight = 25 $button1 = GUICtrlCreateButton("Install A", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight) $buttonTop = $buttonTop + $buttonHeight + 5 $button2 = GUICtrlCreateButton("Install B", $buttonLeft, $buttonTop, $buttonWidth, $buttonHeight) $label1 = GUICtrlCreateLabel("", 185, 50, 70, 25, 0x1000) $label2 = GUICtrlCreateLabel("", 185, 25, 70, 25, 0x1000) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $button1 GUICtrlSetData($label2, "1") GUICtrlSetData($label1, "1") GUISetState(@SW_DISABLE, $gui1) $gui2 = GUICreate("Test Form 2", 270, 180, -1, -1) GUISetState() While 1 $msg2 = GUIGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUISetState(@SW_ENABLE, $gui1) GUIDelete($gui2) ; Not sure what to do at this point??????? Case $msg = $button2 $results = "2" GUICtrlSetData($label2, $results) GUICtrlSetData($label1, "2") EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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