twelo Posted April 7, 2010 Share Posted April 7, 2010 hello i have a script with Parent & Child gui when i open my child gui its working fine but then parent gui not working (menu, command everything does nothing) after closing my child gui parent gui working fine. how child & parent gui both can work together ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 7, 2010 Moderators Share Posted April 7, 2010 twelo,Are you using GetMessage mode? If so, then are you looking for the parent and child events in the same loop?As always, it would be much easier to make sensible suggestions if you were to post some code showing the problem. 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...
twelo Posted April 7, 2010 Author Share Posted April 7, 2010 here is a sample code with PARENT & CHILD GUI when child gui opened "BUTTON 2" working but "BUTTON 1" and other menu controls not working in parent gui how to get working all buttons & menu items of both parent & child window at same time ? expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> #include <String.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <GuiMenu.au3> $PARENT = GUICreate("PARENT", 300, 300, -1, -1, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_ACCEPTFILES,$WS_EX_WINDOWEDGE)) $File = GUICtrlCreateMenu("File") $2ndGUI = GUICtrlCreateMenuItem("Child Win", $File) $About = GUICtrlCreateMenuItem("About", $File) $Button1 = GUICtrlCreateButton("BUTTON 1", 100, 125, 100, 50, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $About MsgBox(8192, "about", "Parent Child Windows") Case $nMsg = $Button1 MsgBox(8192, "1st Msg", "hello this is parent window") Case $nMsg = $2ndGUI $CHILD = GUICreate("CHILD", 200, 200, -1, -1, BitOR($WS_MAXIMIZEBOX,$WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_OVERLAPPEDWINDOW,$WS_TILEDWINDOW,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_TABSTOP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_WINDOWEDGE,$WS_EX_MDICHILD), $PARENT) $Button2 = GUICtrlCreateButton("BUTTON 2", 50, 100, 100, 50, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMg = GUIGetMsg() Switch $nMg Case $GUI_EVENT_CLOSE GUIDelete($CHILD) ExitLoop Case $Button2 MsgBox(8192, "2nd Msg", "hello this is child window") EndSwitch WEnd EndSelect WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 7, 2010 Moderators Share Posted April 7, 2010 twelo,My guess was correct - you need to poll the events in both windows.If you are doing this, it is best to use the "advanced" parameter of GUIGetMsg so you can differentiate between the windows - if you do not, you cannot tell the difference between a $GUI_EVENT_CLOSE from the parent or the child.Here is a short example based on your script to show you want I mean. I have changed the Selects to Switches - I think it is clearer :expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> #include <String.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <GuiMenu.au3> $PARENT = GUICreate("PARENT", 300, 300, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) $File = GUICtrlCreateMenu("File") $2ndGUI = GUICtrlCreateMenuItem("Child Win", $File) $About = GUICtrlCreateMenuItem("About", $File) $Button1 = GUICtrlCreateButton("BUTTON 1", 100, 125, 100, 50, $WS_GROUP) GUISetState(@SW_SHOW) While 1 ; Here we have only 1 GUI to worry about, so we can use the "normal" GUIGetMsg Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $About MsgBox(8192, "about", "Parent Child Windows") Case $Button1 MsgBox(8192, "1st Msg", "hello this is parent window") Case $2ndGUI _Create_Child() ; I have only separated this out into a function for clarity EndSwitch WEnd Func _Create_Child() $CHILD = GUICreate("CHILD", 200, 200, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_WINDOWEDGE, $WS_EX_MDICHILD), $PARENT) $Button2 = GUICtrlCreateButton("BUTTON 2", 50, 100, 100, 50, $WS_GROUP) GUISetState(@SW_SHOW) ; We have 2 GUIs, so use the "advanced" parameter for GUIGetMsg While 1 $aMsg = GUIGetMsg(1) ; We get an array returned with the "advanced" parameter - [1] = GUI, [0] = ControlID/EventID Switch $aMsg[1] ; All these events took place in the Parent GUI Case $PARENT Switch $aMsg[0] Case $GUI_EVENT_CLOSE ; We know this is the parent so we can exit Exit Case $About MsgBox(8192, "about", "Parent Child Windows") Case $Button1 MsgBox(8192, "1st Msg", "hello this is parent window") ; Note there is no case for creatign a second GUI - we already have it! EndSwitch ; All these events were in the Child GUI Case $CHILD Switch $aMsg[0] Case $GUI_EVENT_CLOSE ; We know this is the Child, so only close it, not full exit GUIDelete($CHILD) ExitLoop Case $Button2 MsgBox(8192, "2nd Msg", "hello this is child window") EndSwitch EndSwitch WEnd EndFuncI have commented liberally - I hope everything is clear. M23 dynamitemedia 1 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...
twelo Posted April 7, 2010 Author Share Posted April 7, 2010 Yes now working both thanks for the example & clarification but in above script cases of parent gui also declared in child gui function...(means twice) i know it is necessary, but in larger scripts where parent gui doing 80% functions. Through this way the whole scripts will be much larger & messy. any way to doing this without twice entries ? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 7, 2010 Moderators Share Posted April 7, 2010 twelo, any way to doing this without twice entries ?Yes, like this: expandcollapse popup#include <GUIConstants.au3> #include <Misc.au3> #include <String.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <ButtonConstants.au3> #include <GuiMenu.au3> $PARENT = GUICreate("PARENT", 300, 300, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_ACCEPTFILES, $WS_EX_WINDOWEDGE)) $File = GUICtrlCreateMenu("File") $2ndGUI = GUICtrlCreateMenuItem("Child Win", $File) $About = GUICtrlCreateMenuItem("About", $File) $Button1 = GUICtrlCreateButton("BUTTON 1", 100, 125, 100, 50, $WS_GROUP) GUISetState(@SW_SHOW) $CHILD = GUICreate("CHILD", 200, 200, -1, -1, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS), BitOR($WS_EX_WINDOWEDGE, $WS_EX_MDICHILD), $PARENT) $Button2 = GUICtrlCreateButton("BUTTON 2", 50, 100, 100, 50, $WS_GROUP) GUISetState(@SW_HIDE) While 1 $aMsg = GUIGetMsg(1) ; We get an array returned with the "advanced" parameter - [1] = GUI, [0] = ControlID/EventID Switch $aMsg[1] ; All these events took place in the Parent GUI Case $PARENT ConsoleWrite($aMsg[0] & @CRLF) Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $About MsgBox(8192, "about", "Parent Child Windows") Case $Button1 MsgBox(8192, "1st Msg", "hello this is parent window") Case $2ndGUI GUISetState(@SW_SHOW, $CHILD) EndSwitch ; All these events were in the Child GUI - if it exists! Case $CHILD Switch $aMsg[0] Case $GUI_EVENT_CLOSE ; We know this is the Child, so only close it, not full exit GUISetState(@SW_HIDE, $CHILD) Case $Button2 MsgBox(8192, "2nd Msg", "hello this is child window") EndSwitch EndSwitch WEnd You just create all the GUIs first and then hide/show them as required. It means you get a big loop, but it does what you want. 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...
twelo Posted April 7, 2010 Author Share Posted April 7, 2010 I think 1st option is much better than 2nd non stop loop option only i have to assign necessary actions of parent window in child window function, not all thanks for giving these options 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