Sign in to follow this  
Followers 0
twelo

When Child GUI Working - Parent GUI Not

7 posts in this topic

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 ?

Share this post


Link to post
Share on other sites



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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 ?

#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

Share this post


Link to post
Share on other sites

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 :( :

#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

EndFunc

I have commented liberally - I hope everything is clear. :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

twelo,

any way to doing this without twice entries ?

Yes, like this:

#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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 :(

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0