au3scr Posted December 22, 2008 Share Posted December 22, 2008 (edited) Hi does anyone know why script closes all GUIs if I click on 2nd gui close button? How I can code it thatway if I close second window, then main window stay not closed? #include <GUIConstantsEx.au3> $Form1_1 = GUICreate("title", 612, 402, 194, 126) $button = GUICtrlCreateButton("new gui", 3, 3, 75, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If $nMsg[1] = $Form1_1 Then Exit;Exit if main window was closed GUIDelete($nMsg[1]);Delete the second form If $nMsg[1] = $Form1_1 Then Exit GUIDelete($nMsg[1]) Case $button $Form2 = GUICreate("Form2", 116, 26, 193, 125) GUISetState(@SW_SHOW) EndSwitch WEnd Error: Z:\dff\desktop-5-12-2008\vaatabmissaab.au3 (10) : ==> Subscript used with non-Array variable.: If $nMsg[1] = $Form1_1 Then Exit If $nMsg^ ERROR Edited December 22, 2008 by au3scr Link to comment Share on other sites More sharing options...
AlmarM Posted December 22, 2008 Share Posted December 22, 2008 Mayby could take a look at this: #include <GUIConstants.au3> $MainGUI = GUICreate("EXAMPLE", 200, 200, -1, -1) $Button1 = GUICtrlCreateButton("CREATE", 10, 10, 180, 180) GUISetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 ; $GUI_EVENT_CLOSE Exit Case $nMsg = $Button1 GUISetState(@SW_DISABLE, $MainGUI) ; Just an extra effect _MyFunc() EndSelect WEnd Func _MyFunc() $SecondGUI = GUICreate("GUI 2", 100, 100, -1, -1) GUICtrlCreateLabel("Example Label", 10, 10) GUISetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = -3 GUIDelete($SecondGUI) GUISetState(@SW_ENABLE, $MainGUI) ; Just an extra effect GUISetState(@SW_RESTORE, $MainGUI) ; Just an extra effect ExitLoop EndSelect WEnd EndFunc AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
someone Posted December 22, 2008 Share Posted December 22, 2008 Hi does anyone know why script closes all GUIs if I click on 2nd gui close button? How I can code it thatway if I close second window, then main window stay not closed? #include <GUIConstantsEx.au3> $Form1_1 = GUICreate("title", 612, 402, 194, 126) $button = GUICtrlCreateButton("new gui", 3, 3, 75, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE If $nMsg[1] = $Form1_1 Then Exit;Exit if main window was closed GUIDelete($nMsg[1]);Delete the second form If $nMsg[1] = $Form1_1 Then Exit GUIDelete($nMsg[1]) Case $button $Form2 = GUICreate("Form2", 116, 26, 193, 125) GUISetState(@SW_SHOW) EndSwitch WEndoÝ÷ ØJ뢿êº^ì»{®Ø^ë*º+^i¸Âº'ØZµÊxò¢éh¢FBzÓ,)íè^â쨻eÇÊ¡j÷¢ëBzÓ,XÊ°j{m¢ëÙbëajÐ^q«¬zí«n²)àKr7ês,Ú²}ý¶f¤y©ò±éì{*.Á©íKr7ês,E¡ÉÚ2¢èZ½ëax쵫^éí²Ü"qà%²¨ºIèÂØZ´e é^µè¬ij»h~Ø^û-jצz{kmjëh×6While 1 $nMsg = GUIGetMsg(1) Switch $nMsg[0] Case $GUI_EVENT_CLOSE If $nMsg[1] = $Form1_1 Then Exit;Exit if main window was closed Else GUIDelete($nMsg[1]);Delete the second form EndIf Case $button $Form2 = GUICreate("Form2", 116, 26, 193, 125) GUISetState(@SW_SHOW) EndSwitch WEnd While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd 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