DarkBoost Posted February 11, 2009 Share Posted February 11, 2009 I have a simple GUI Parent and Child however when I close the Child it also closes the Parent #Include <GuiConstantsEx.au3> Opt("MustDeclareVars",1) Dim $guimain, $guichild, $guibutton, $msg $guimain = GUICreate("",400,400) $guibutton = GUICtrlCreateButton("child",165,180,60,20) GUISetState(@SW_SHOW, $guimain) While 1 $msg = GUIGetMsg() Select Case $msg = $guibutton $guichild = GUICreate("",200,200) GUISetState(@SW_SHOW, $guichild) Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2009 Moderators Share Posted February 11, 2009 DarkBoost,Use the "advanced" parameter of GUIGetMsg to determine which window is sending the $GUI_EVENT_CLOSE:#Include <GuiConstantsEx.au3> Opt("MustDeclareVars",1) Dim $guimain, $guichild, $guibutton, $array_msg $guimain = GUICreate("",400,400) $guibutton = GUICtrlCreateButton("child",165,180,60,20) GUISetState(@SW_SHOW, $guimain) While 1 $array_msg = GUIGetMsg(1) Switch $array_msg[0] Case $guibutton $guichild = GUICreate("",200,200) GUISetState(@SW_SHOW, $guichild) Case $GUI_EVENT_CLOSE Switch $array_msg[1] Case $guichild GUISetState(@SW_HIDE, $guichild) Case $guimain Exit EndSwitch EndSwitch WEndM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DarkBoost Posted February 11, 2009 Author Share Posted February 11, 2009 @Melba23: That makes sense, thank you very much! Link to comment Share on other sites More sharing options...
CodyBarrett Posted February 11, 2009 Share Posted February 11, 2009 OR you could just Hide the child.... but what ever you want [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
DarkBoost Posted February 11, 2009 Author Share Posted February 11, 2009 I originally tried using Hide the child but was unable to show it again when clicking the button a second time. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2009 Moderators Share Posted February 11, 2009 DarkBoost, If you want the window to be created once, hidden on exit and then shown again each time you press the button, use this:#Include <GuiConstantsEx.au3> Opt("MustDeclareVars",1) Dim $guimain, $guichild, $guibutton, $array_msg $guimain = GUICreate("",400,400) $guibutton = GUICtrlCreateButton("child",165,180,60,20) GUISetState(@SW_SHOW, $guimain) $guichild = GUICreate("",200,200) GUISetState(@SW_HIDE, $guichild) While 1 $array_msg = GUIGetMsg(1) Switch $array_msg[0] Case $guibutton GUISetState(@SW_SHOW, $guichild) Case $GUI_EVENT_CLOSE Switch $array_msg[1] Case $guichild GUISetState(@SW_HIDE, $guichild) Case $guimain Exit EndSwitch EndSwitch WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DarkBoost Posted February 11, 2009 Author Share Posted February 11, 2009 Thank you very much Melba23 both examples have been very helpful. New question, where do I put my code to control a button on the child window? Link to comment Share on other sites More sharing options...
Malkey Posted February 12, 2009 Share Posted February 12, 2009 Thank you very much Melba23 both examples have been very helpful. New question, where do I put my code to control a button on the child window?This way works.#include <GuiConstantsEx.au3> Opt("MustDeclareVars", 1) Dim $guimain, $guichild, $guibutton, $array_msg, $guichildbutton $guimain = GUICreate("", 400, 400) $guibutton = GUICtrlCreateButton("child", 165, 180, 60, 20) GUISetState(@SW_SHOW, $guimain) $guichild = GUICreate("", 200, 200) $guichildbutton = GUICtrlCreateButton("Button on child", 60, 90, 80, 20) GUISetState(@SW_HIDE, $guichild) While 1 $array_msg = GUIGetMsg(1) Switch $array_msg[0] Case $guibutton GUISetState(@SW_SHOW, $guichild) Case $guichildbutton MsgBox(0, "", "Button on Child") Case $GUI_EVENT_CLOSE Switch $array_msg[1] Case $guichild GUISetState(@SW_HIDE, $guichild) Case $guimain Exit EndSwitch EndSwitch 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