grimreaper Posted March 19, 2008 Posted March 19, 2008 (edited) Hello, I have written a small gui to test some stuff, but now i have made a child window, and when i close the child the whole program is closed. does anybody know how i could prevent the program to close when i close a child window i have te code from several tutorials found on the internet While 1 $msg = GUIGetMsg() Select Case $msg = $MenuExit ExitLoop Case $msg = $MenuHelp $child = GUICreate( "Help", 500, 500, 20, 20, -1, -1, $wnd) $Text = GUICtrlCreateEdit( "", 0, 0 , 500, 500, BitOR($ES_MULTILINE, $ES_READONLY) ) GUICtrlSetData($Text, "test, " & @CRLF & @CRLF & "test", 1) GUISetState( @SW_SHOW ) Case $msg = $startButton Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd i just started a few days ago so please comment anything you see that could also be done better Edited March 19, 2008 by grimreaper
spudw2k Posted March 19, 2008 Posted March 19, 2008 (edited) I had a problem like this once too. How I got passed it was like this. If $msg = $GUI_EVENT_CLOSE Then If WinActive("This GUI Title") Then GUISwitch($tGui) ;Other gui GUIDelete() Else Exit EndIf EndIf 100th Post - Woot! Edited March 19, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
grimreaper Posted March 19, 2008 Author Posted March 19, 2008 That worked Thanks if there is a better solution for later purposes i like to hear it but in the mean while thanks
rasim Posted March 21, 2008 Posted March 21, 2008 That worked Thanks if there is a better solution for later purposes i like to hear it but in the mean while thanksTry this: #include <GuiConstants.au3> $hMainGUI = GUICreate("Main GUI", 300, 200) $SwitchButton = GUICtrlCreateButton("Switch", 100, 50, 60, 25) $hChildGUI = GUICreate("Child GUI", 200, 100, -1, -1, -1, -1, $hMainGUI) GUISetState(@SW_SHOW, $hMainGUI) While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $hMainGUI ExitLoop Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $hChildGUI GUISetState(@SW_ENABLE, $hMainGUI) GUISetState(@SW_HIDE, $hChildGUI) Case $msg[0] = $SwitchButton GUISetState(@SW_DISABLE, $hMainGUI) GUISetState(@SW_SHOW, $hChildGUI) EndSelect WEnd
grimreaper Posted March 21, 2008 Author Posted March 21, 2008 While 1 $msg = GUIGetMsg(1) Select Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $hMainGUI ExitLoop Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $hChildGUI GUISetState(@SW_ENABLE, $hMainGUI) GUISetState(@SW_HIDE, $hChildGUI) Case $msg[0] = $SwitchButton GUISetState(@SW_DISABLE, $hMainGUI) GUISetState(@SW_SHOW, $hChildGUI) EndSelect WEnd That seems like a better solution, Thanks
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