Jump to content
Sign in to follow this  
l4tran

How to interact with Parent from Child gui?

Recommended Posts

l4tran

Hello everyone,

I have created parent/child gui windows, how I do draw objects in Parents from Child?

#include<file.au3>
#include<array.au3>
#include<GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <WinAPI.au3>
#include <GuiMenu.au3>
$parentx = 1200
$parenty = 700

$parent = GUICreate("Management", $parentx, $parenty, -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_menu = GUICtrlCreateMenu("File")
$exit_item = GUICtrlCreateMenuItem("Exit", $file_menu)
$tool_menu = GUICtrlCreateMenu("Tools")
$setup_item = GUICtrlCreateMenuItem("Setup", $tool_menu)
$help_menu = GUICtrlCreateMenu("Help")
$about_item = GUICtrlCreateMenuItem("About", $help_menu)
GUICtrlCreateGroup("Section E", 10, 10, 400, 400)
#cs
$Sections = IniReadSectionNames(@ScriptDir & "\wok-sections.ini")
For $i = 1 To UBound($Sections) - 1
    $Tables = IniReadSection(@ScriptDir & "\wok-sections.ini", $Sections[$i])
    If IsArray($Tables) Then
        For $j = 1 To UBound($Tables) - 1
            $Table_values = IniReadSection(@ScriptDir & "\wok-tables.ini", $Tables[$j][1])
            If IsArray($Table_values) Then
                $dimension = IniReadSection(@ScriptDir & "\wok-tabledimension.ini", $Table_values[3][1])
                ;_ArrayDisplay($dimension)
                $Tables[$j][0] = GUICtrlCreateButton($Tables[$j][1], Int($Table_values[1][1]), Int($Table_values[2][1]), Int($dimension[1][1]), Int($dimension[2][1]))
                If Not (StringInStr($Table_values[3][1], "rec")) Then GUICtrlSetImage(-1, $dimension[3][1])
            EndIf
        Next
    EndIf
Next
#ce
GUISetState(@SW_SHOW)

$child = GUICreate("Phim 88 ", 500, 400, -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)
GUICtrlCreateGroup("Add Table(s)", 10, 10, 480, 380)
GUICtrlCreateLabel("Section", 20, 30, 40)
$Section = GUICtrlCreateCombo("", 60, 25, 75, 20)
GUICtrlSetData(-1, "Section-A|Section-B|Section-C|Section-D|Section-E|Section-F", "")
GUICtrlCreateLabel("Name", 20, 60, 40)
$Name = GUICtrlCreateInput("", 60, 55, 75, 20)
GUICtrlCreateLabel("Top", 140, 30, 40)
$top = GUICtrlCreateInput("", 170, 25, 40, 20)
GUICtrlCreateLabel("Left", 140, 60, 40)
$left = GUICtrlCreateInput("", 170, 55, 40, 20)
GUICtrlCreateLabel("Shape", 220, 30, 40)
$shape = GUICtrlCreateCombo("", 260, 25, 135, 20)
GUICtrlSetData(-1, "recv-4ppl|rech-4ppl|oval-8ppl", "recv-4ppl")
GUICtrlCreateLabel("Image", 220, 60, 40)
$image = GUICtrlCreateInput("", 260, 55, 135, 20)
$btn1=GUICtrlCreateButton("Create Grid in Parent",70,90,200)
GUISetState(@SW_HIDE)

While 1
    $aMsg = GUIGetMsg(1) 
    Switch $aMsg[1]
        Case $parent
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $about_item
                    MsgBox(8192, "about", "Parent Child Windows")
                Case $setup_item
                    GUISetState(@SW_SHOW, $child)
            EndSwitch
        Case $child
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE 
                    GUISetState(@SW_HIDE, $child)
                Case $Section
                    $Tables = IniReadSection(@ScriptDir & "\wok-sections.ini", GUICtrlRead($Section))
                    If IsArray($Tables) Then
                        $num = Int(StringRight($Tables[UBound($Tables) - 1][1], 2)) + 1
                        GUICtrlSetData($Name, StringRight(GUICtrlRead($Section), 1) & String($num))
                    Else
                        GUICtrlSetData($Name, StringRight(GUICtrlRead($Section), 1) & "1")
                        _ArrayDisplay($Tables)
                    EndIf
                Case $btn1
                    drawgrid()
                    MsgBox(0,"","I want to draw the grid numbers in the parent windows from here")
            EndSwitch
    EndSwitch
WEnd

Func drawgrid()
    Dim $gridx[1], $gridy[1]
    $i = 0
    For $x = 0 To $parentx Step 50
        ReDim $gridx[UBound($gridx) + 1]
        $gridx[$i] = GUICtrlCreateLabel($x, $x, 0, 20, 20)
        GUICtrlSetState(-1, $gui_disable)
        $i += 1
    Next
    $i = 0
    For $y = 0 To $parenty Step 50
        ReDim $gridy[UBound($gridy) + 1]
        $gridx[$i] = GUICtrlCreateLabel($y, 0, $y, 20, 20)
        GUICtrlSetState(-1, $gui_disable)
        $i += 1
    Next
EndFunc   ;==>drawgrid

Share this post


Link to post
Share on other sites
Melba23

l4tran,

Use GUISwitch to select the active GUI. :)

M23

P.S. I have deleted your necro-post asking the same thing - please just stick to one thread at a time in future. ;)


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

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  

×