Sign in to follow this  
Followers 0
ZenKensei

Returning data from ChildGUI to MainGUI

2 posts in this topic

Group,

Bear with me on this, this is my first time working with child gui's. After looking at the example included with Autoit, I see how the child gui is called from the parent gui. And I think I realize how to make actions happen on the child gui say independent of the parent gui. What I'm curious about, and what I'm working on is a child gui that returns data back to the parent gui, say as a variable. Please see the 2 examples below:

Parent gui is listed first

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 282, 441, 192, 113)
$Button1 = GUICtrlCreateButton("Switch Name", 24, 24, 73, 25)
GUICtrlSetTip(-1, "Start Child Menu")
$Input1 = GUICtrlCreateInput("AInput1", 112, 24, 145, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "Returned from ChildGUI")
$Button2 = GUICtrlCreateButton("Ok", 24, 80, 73, 25)
$Button3 = GUICtrlCreateButton("Exit", 184, 80, 73, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;;;;;
    EndSelect
WEnd
Exit

The 'Switch Name' button from the parent gui needs to call the child gui which is listed Next:

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$CiscoNamer = GUICreate("Cisco Switch Namer", 217, 394, 367, 114)
GUICtrlCreateLabel("Division:", 24, 16, 55, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Choose the Division")
$ADivCombo1 = GUICtrlCreateCombo("", 88, 16, 105, 21)
GUICtrlSetData(-1, "AA|BB|CC")
GUICtrlSetTip(-1, "Choose Division")
GUICtrlCreateLabel("Site ID:", 24, 56, 46, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Divisional Site ID")
$ASiteCombo1 = GUICtrlCreateCombo("", 88, 56, 105, 21)
GUICtrlSetData(-1, "000|001|002|003|004|005")
GUICtrlSetTip(-1, "Choose Site ID")
GUICtrlCreateLabel("Pad ID:", 24, 96, 48, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Choose PAD ID")
$APadCombo1 = GUICtrlCreateCombo("", 88, 96, 105, 21)
GUICtrlSetData(-1, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P")
GUICtrlSetTip(-1, "Choose the site Pad ID")
GUICtrlCreateLabel("Class ID:", 24, 136, 57, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Class ID is Fixed")
$AClassCombo1 = GUICtrlCreateCombo("", 88, 136, 105, 21)
GUICtrlSetData(-1, "N")
GUICtrlSetTip(-1, "Class ID Fixed")
GUICtrlCreateLabel("Model:", 24, 176, 45, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$AModelCombo1 = GUICtrlCreateCombo("", 88, 176, 105, 21)
GUICtrlSetData(-1, "1900|2900|3500|3700")
GUICtrlSetTip(-1, "Select Switch Model")
GUICtrlCreateLabel("Closet:", 24, 216, 45, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Select the Switch Closet")
$AClosetCombo1 = GUICtrlCreateCombo("", 88, 216, 105, 21)
GUICtrlSetData(-1, "POS|STO")
GUICtrlSetTip(-1, "Select Switch Closet")
GUICtrlCreateLabel("Series:", 24, 256, 46, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Switch Series")
$ASeriesCombo1 = GUICtrlCreateCombo("", 88, 256, 105, 21)
GUICtrlSetData(-1, "01|02|03|04|05")
GUICtrlSetTip(-1, "Select Series Switch")
$Button1 = GUICtrlCreateButton("OK", 24, 344, 65, 25)
GUICtrlSetTip(-1, "Accept Switch Name")
$Button2 = GUICtrlCreateButton("Clear", 128, 344, 65, 25)
GUICtrlSetTip(-1, "Clear the Form")
$ASwitchInput1 = GUICtrlCreateInput("", 24, 296, 169, 24, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetTip(-1, "Switch Name")
$DivID = (GUICtrlRead($ADivCombo1))
GUICtrlSetData(-1, $DivID)

GUISetState(@SW_SHOW)
While 1
    $DivID = (GUICtrlRead($ADivCombo1))
    $SiteID = (GUICtrlRead($ASiteCombo1))
    $PadID = (GUICtrlRead($APadCombo1))
    $ClassID = (GUICtrlRead($AClassCombo1))
    $ModelID = (GUICtrlRead($AModelCombo1))
    $ClosetID = (GUICtrlRead($AClosetCombo1))
    $SeriesID = (GUICtrlRead($ASeriesCombo1))

GUICtrlSetData(-1, $DivID & $SiteID & $PadID & $ClassID & $ModelID & $ClosetID & $SeriesID)
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg == ($Button1)
         MsgBox(4096,"Switch Name", "Switch Name")
    Case $msg == ($Button2)
         MsgBox(4096,"Clear Form", "Clear Form")             
    EndSelect
WEnd
Exit

Once the user has selected all of the boxes and the name is in the input box at the bottom, I want that name returned to the parent gui and placed in the 'input box' to the right of switch name when the user presses 'Ok' on the child gui. This will then become a variable to be used later in the actual gui I'm writing.

As always, thanks in advance for any help or advice with this.

ZenKensei

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("AForm1", 282, 441, 192, 113)
$Button1 = GUICtrlCreateButton("Switch Name", 24, 24, 73, 25)
GUICtrlSetTip(-1, "Start Child Menu")
$Input1 = GUICtrlCreateInput("AInput1", 112, 24, 145, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetTip(-1, "Returned from ChildGUI")
$Button2 = GUICtrlCreateButton("Ok", 24, 80, 73, 25)
$Button3 = GUICtrlCreateButton("Exit", 184, 80, 73, 25)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button1
            GUICtrlSetData($Input1, _GuiChild())
        Case Else
        ;;;;;;;
    EndSelect
WEnd
Exit

Func _GuiChild()
; == GUI generated with Koda ==
    $CiscoNamer = GUICreate("Cisco Switch Namer", 217, 394, 367, 114)
    GUICtrlCreateLabel("Division:", 24, 16, 55, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetTip(-1, "Choose the Division")
    $ADivCombo1 = GUICtrlCreateCombo("", 88, 16, 105, 21)
    GUICtrlSetData(-1, "AA|BB|CC")
    GUICtrlSetTip(-1, "Choose Division")
    GUICtrlCreateLabel("Site ID:", 24, 56, 46, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetTip(-1, "Divisional Site ID")
    $ASiteCombo1 = GUICtrlCreateCombo("", 88, 56, 105, 21)
    GUICtrlSetData(-1, "000|001|002|003|004|005")
    GUICtrlSetTip(-1, "Choose Site ID")
    GUICtrlCreateLabel("Pad ID:", 24, 96, 48, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetTip(-1, "Choose PAD ID")
    $APadCombo1 = GUICtrlCreateCombo("", 88, 96, 105, 21)
    GUICtrlSetData(-1, "A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P")
    GUICtrlSetTip(-1, "Choose the site Pad ID")
    GUICtrlCreateLabel("Class ID:", 24, 136, 57, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetTip(-1, "Class ID is Fixed")
    $AClassCombo1 = GUICtrlCreateCombo("", 88, 136, 105, 21)
    GUICtrlSetData(-1, "N")
    GUICtrlSetTip(-1, "Class ID Fixed")
    GUICtrlCreateLabel("Model:", 24, 176, 45, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    $AModelCombo1 = GUICtrlCreateCombo("", 88, 176, 105, 21)
    GUICtrlSetData(-1, "1900|2900|3500|3700")
    GUICtrlSetTip(-1, "Select Switch Model")
    GUICtrlCreateLabel("Closet:", 24, 216, 45, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetTip(-1, "Select the Switch Closet")
    $AClosetCombo1 = GUICtrlCreateCombo("", 88, 216, 105, 21)
    GUICtrlSetData(-1, "POS|STO")
    GUICtrlSetTip(-1, "Select Switch Closet")
    GUICtrlCreateLabel("Series:", 24, 256, 46, 20)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetTip(-1, "Switch Series")
    $ASeriesCombo1 = GUICtrlCreateCombo("", 88, 256, 105, 21)
    GUICtrlSetData(-1, "01|02|03|04|05")
    GUICtrlSetTip(-1, "Select Series Switch")
    $Button1 = GUICtrlCreateButton("OK", 24, 344, 65, 25)
    GUICtrlSetTip(-1, "Accept Switch Name")
    $Button2 = GUICtrlCreateButton("Clear", 128, 344, 65, 25)
    GUICtrlSetTip(-1, "Clear the Form")
    $ASwitchInput1 = GUICtrlCreateInput("", 24, 296, 169, 24, -1, $WS_EX_CLIENTEDGE)
    GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
    GUICtrlSetTip(-1, "Switch Name")
    $DivID = (GUICtrlRead($ADivCombo1))
    GUICtrlSetData(-1, $DivID)
    
    GUISetState(@SW_SHOW)
    While 1
        $DivID = (GUICtrlRead($ADivCombo1))
        $SiteID = (GUICtrlRead($ASiteCombo1))
        $PadID = (GUICtrlRead($APadCombo1))
        $ClassID = (GUICtrlRead($AClassCombo1))
        $ModelID = (GUICtrlRead($AModelCombo1))
        $ClosetID = (GUICtrlRead($AClosetCombo1))
        $SeriesID = (GUICtrlRead($ASeriesCombo1))
        
        GUICtrlSetData($ASwitchInput1, $DivID & $SiteID & $PadID & $ClassID & $ModelID & $ClosetID & $SeriesID)
        $msg2 = GUIGetMsg()
        Select
            Case $msg2 = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg2 == ($Button1)
                MsgBox(4096, "Switch Name", "Switch Name")
            Case $msg2 == ($Button2)
                MsgBox(4096, "Clear Form", "Clear Form")
        EndSelect
    WEnd
    $tmp = GUICtrlRead($ASwitchInput1)
    GUIDelete($CiscoNamer)
    Return $tmp
EndFunc  ;==>_GuiChild

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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