Laymanball Posted October 25, 2011 Share Posted October 25, 2011 (edited) Open4Child on the GUI by not close form. expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $hGui, $hParent1, $hParent2, $hParent3, $hParent4 Global $msg, $Btn1, $Btn2, $Btn3, $Btn4 Local $hGui=_CreateGUI("Gui4Child", 420, 200, 400, 300) GUISwitch($hGui) Local $Btn_A=_CreateButton("Child1", 20, 100, 80, 30) Local $Btn_B=_CreateButton("Child2", 120, 100, 80, 30) Local $Btn_C=_CreateButton("Child3", 220, 100, 80, 30) Local $Btn_D=_CreateButton("Child4", 320, 100, 80, 30) GUISwitch($hGui) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Btn_A _SetStateParent1() Case $Btn_B _SetStateParent2() Case $Btn_C _SetStateParent3() Case $Btn_D _SetStateParent4() EndSwitch WEnd Func _SetStateParent1() Local $hParent1=_CreateGUI("Child1", 250, 150, 350, 250) Local $Btn1=_CreateButton("OK", 100, 100, 80, 30) GUISwitch($hParent1) GUISetState(@SW_SHOW, $hParent1) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Btn1 MsgBox(64, "", "Hello! Child1") EndSelect Until False GUIDelete($hParent1) EndFunc Func _SetStateParent2() Local $hParent2=_CreateGUI("Child2", 250, 150, 350, 250) Local $Btn2=_CreateButton("OK", 100, 100, 80, 30) GUISwitch($hParent2) GUISetState(@SW_SHOW, $hParent2) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Btn2 MsgBox(64, "", "Hello! Child2") EndSelect Until False GUIDelete($hParent2) EndFunc Func _SetStateParent3() Local $hParent3=_CreateGUI("Child3", 250, 150, 350, 250) Local $Btn3=_CreateButton("OK", 100, 100, 80, 30) GUISwitch($hParent3) GUISetState(@SW_SHOW, $hParent3) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Btn3 MsgBox(64, "", "Hello! Child3") EndSelect Until False GUIDelete($hParent3) EndFunc Func _SetStateParent4() Local $hParent4=_CreateGUI("Child4", 250, 150, 350, 250) Local $Btn4=_CreateButton("OK", 100, 100, 80, 30) GUISwitch($hParent4) GUISetState(@SW_SHOW, $hParent4) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Btn4 MsgBox(64, "", "Hello! Child4") EndSelect Until False GUIDelete($hParent4) EndFunc Global $Title, $Width, $Height, $Left, $Top Func _CreateGUI($Title, $Width, $Height, $Left, $Top) Local $gRet = (GUICreate($Title, $Width, $Height, $Left, $Top)) Return $gRet EndFunc Global $BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight Func _CreateButton($BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight) Local $bRet = (GUICtrlCreateButton($BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight)) Return $bRet EndFunc ;==>FormObjectCreateGui4Child.OR Hidden GUI when choose show child and If exit child form will show.expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $hGui, $hParent1, $hParent2, $hParent3, $hParent4 Global $msg, $Btn1, $Btn2, $Btn3, $Btn4 Local $hGui=_CreateGUI("Gui4Child", 420, 200, -1, -1) GUISwitch($hGui) Local $Btn_A=_CreateButton("Child1", 20, 100, 80, 30) Local $Btn_B=_CreateButton("Child2", 120, 100, 80, 30) Local $Btn_C=_CreateButton("Child3", 220, 100, 80, 30) Local $Btn_D=_CreateButton("Child4", 320, 100, 80, 30) GUISwitch($hGui) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Btn_A GUISetState(@SW_HIDE, $hGui) _SetStateParent1() Case $Btn_B GUISetState(@SW_HIDE, $hGui) _SetStateParent2() Case $Btn_C GUISetState(@SW_HIDE, $hGui) _SetStateParent3() Case $Btn_D GUISetState(@SW_HIDE, $hGui) _SetStateParent4() EndSwitch WEnd Func _SetStateParent1() Local $hParent1=_CreateGUI("Child1", 250, 150, -1, -1) Local $Btn1=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent1) GUISetState(@SW_SHOW, $hParent1) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn1 MsgBox(64, "", "Hello! Child1") EndSelect Until False GUIDelete($hParent1) EndFunc Func _SetStateParent2() Local $hParent2=_CreateGUI("Child2", 250, 150, -1, -1) Local $Btn2=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent2) GUISetState(@SW_SHOW, $hParent2) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn2 MsgBox(64, "", "Hello! Child2") EndSelect Until False GUIDelete($hParent2) EndFunc Func _SetStateParent3() Local $hParent3=_CreateGUI("Child3", 250, 150, -1, -1) Local $Btn3=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent3) GUISetState(@SW_SHOW, $hParent3) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn3 MsgBox(64, "", "Hello! Child3") EndSelect Until False GUIDelete($hParent3) EndFunc Func _SetStateParent4() Local $hParent4=_CreateGUI("Child4", 250, 150, -1, -1) Local $Btn4=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent4) GUISetState(@SW_SHOW, $hParent4) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn4 MsgBox(64, "", "Hello! Child4") EndSelect Until False GUIDelete($hParent4) EndFunc Global $Title, $Width, $Height, $Left, $Top Func _CreateGUI($Title, $Width, $Height, $Left, $Top) Local $gRet = (GUICreate($Title, $Width, $Height, $Left, $Top)) Return $gRet EndFunc Global $BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight Func _CreateButton($BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight) Local $bRet = (GUICtrlCreateButton($BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight)) Return $bRet EndFunc ;==>FormObjectCreateGui4Child.Add Child5. Confirm Exit Message.expandcollapse popup#NoTrayIcon #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Global $hGui, $hParent1, $hParent2, $hParent3, $hParent4, $hParent5 Global $msg, $Btn1, $Btn2, $Btn3, $Btn4, $Btn_OK, $Btn_Cancel Local $hGui=_CreateGUI("Gui4Child", 420, 200, -1, -1) GUISwitch($hGui) Local $Btn_A=_CreateButton("Child1", 20, 100, 80, 30) Local $Btn_B=_CreateButton("Child2", 120, 100, 80, 30) Local $Btn_C=_CreateButton("Child3", 220, 100, 80, 30) Local $Btn_D=_CreateButton("Child4", 320, 100, 80, 30) GUISwitch($hGui) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _GuiExitMessage() Case $Btn_A GUISetState(@SW_HIDE, $hGui) _SetStateParent1() Case $Btn_B GUISetState(@SW_HIDE, $hGui) _SetStateParent2() Case $Btn_C GUISetState(@SW_HIDE, $hGui) _SetStateParent3() Case $Btn_D GUISetState(@SW_HIDE, $hGui) _SetStateParent4() EndSwitch WEnd Func _SetStateParent1() Local $hParent1=_CreateGUI("Child1", 250, 150, -1, -1) Local $Btn1=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent1) GUISetState(@SW_SHOW, $hParent1) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn1 MsgBox(64, "", "Hello! Child1") EndSelect Until False GUIDelete($hParent1) EndFunc Func _SetStateParent2() Local $hParent2=_CreateGUI("Child2", 250, 150, -1, -1) Local $Btn2=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent2) GUISetState(@SW_SHOW, $hParent2) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn2 MsgBox(64, "", "Hello! Child2") EndSelect Until False GUIDelete($hParent2) EndFunc Func _SetStateParent3() Local $hParent3=_CreateGUI("Child3", 250, 150, -1, -1) Local $Btn3=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent3) GUISetState(@SW_SHOW, $hParent3) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn3 MsgBox(64, "", "Hello! Child3") EndSelect Until False GUIDelete($hParent3) EndFunc Func _SetStateParent4() Local $hParent4=_CreateGUI("Child4", 250, 150, -1, -1) Local $Btn4=_CreateButton("OK", 80, 100, 80, 30) GUISwitch($hParent4) GUISetState(@SW_SHOW, $hParent4) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUISetState(@SW_SHOW, $hGui) ExitLoop Case $msg = $Btn4 MsgBox(64, "", "Hello! Child4") EndSelect Until False GUIDelete($hParent4) EndFunc Global $Title, $Width, $Height, $Left, $Top Func _CreateGUI($Title, $Width, $Height, $Left, $Top) Local $gRet = (GUICreate($Title, $Width, $Height, $Left, $Top)) Return $gRet EndFunc Global $BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight Func _CreateButton($BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight) Local $bRet = (GUICtrlCreateButton($BtnName, $BtnLeft, $BtnTop, $BtnWidth, $BtnHeight)) Return $bRet EndFunc ;==>FormObjectCreateGui4Child. Func _GuiExitMessage() $hParent5=_CreateGUI("Child5", 257, 107, -1, -1) WinSetOnTop("Child5", "", 1) $Btn_OK=_CreateButton("OK", 40, 64, 75, 25) $Btn_Cancel=_CreateButton("Cancel", 136, 64, 75, 25) GUICtrlCreateIcon("C:\WINDOWS\system32\ahui.exe", -1, 16, 16, 32, 32, BitOR($SS_NOTIFY,$WS_GROUP)) GUICtrlCreateLabel("Do you wanted to Exit?", 72, 24, 114, 17) GUISwitch($hParent5) GUISetState(@SW_SHOW, $hParent5) Do $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE GUIDelete($hParent5) ExitLoop Case $msg = $Btn_OK GUIDelete($hGui) GUIDelete($hParent5) Exit Case $msg = $Btn_Cancel GUIDelete($hParent5) ExitLoop EndSelect Until False EndFunc Edited October 27, 2011 by Laymanball My Sample Script Download: VistaDesktopIconsChangerForXp.au3 (Com,Doc and Bin only) http://www.4shared.com/rar/NMHYL5Igba/VistaDesktopIconsChangerForXp_.html VistaDesktopIconsChangerForXp.exe (Resources) http://www.4shared.com/rar/nzs7Mb1gba/VistaDesktopIconsChangerForXp_.html Link to comment Share on other sites More sharing options...
bogQ Posted October 25, 2011 Share Posted October 25, 2011 well that's the problem when every of your gui`s have seperate loop inside it self. TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
martin Posted October 25, 2011 Share Posted October 25, 2011 Or to put bogQ's point with a bit more information; It is better to have one while loop which handles the events from all windows and controls. Make sure that you do not duplicate control variable names. The problem is that Gui events like$GUI_EVENT_CLOSEare the same whichever window they come from, so you have to use a method which allows you to tell which window generated the event. Look upGuiGetMsgin the help and study the advanced parameter. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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