Jump to content
232showtime

Help, GUI Parent & Child Script

Recommended Posts

232showtime

Hello World!!!,

Please I need help for my script I am really stuck...

I tried different ways but still has a problem

1st Attempt: "Test Button not working"

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIListViewEx.au3>

$guimain = GUICreate("Form1", 960, 540, 150, 100, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_CLIPCHILDREN, $WS_TABSTOP))




Local $idFilemenu = GUICtrlCreateMenu("&File")
Local $idRunmenu = GUICtrlCreateMenu("&Edit")
Local $idViewmenu = GUICtrlCreateMenu("&View")
Local $sInput0 = GUICtrlCreateInput("", 900, 50, 50, 20)


$Child0 = GUICtrlCreateButton("Child", 900, 0, 50, 20)
$List1 = GUICtrlCreateListView("", 0, 0, 500, 500, BitOR(0x0200, 0x008), BitOR(0x00000020, 0x00000001))

_GUICtrlListView_AddColumn($List1, "Col1", 150, 2)
_GUICtrlListView_AddColumn($List1, "Col2", 500, 2)
_GUICtrlListView_AddColumn($List1, "Col3", 50, 2)
_GUICtrlListView_Scroll($List1, 10, 100)

GUISetState(@SW_SHOW, $guimain)

While 1

    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $Child0
            $Child1 = GUICreate("", 401, 488, 192, 124)
            $sLabel = GUICtrlCreateLabel("", 24, 16, 73, 17)
            $sInput1 = GUICtrlCreateInput("", 112, 16, 265, 21)
            $Test = GUICtrlCreateButton("Test", 72, 392, 75, 25)
            GUISetState(@SW_SHOW, $Child1)
            GUISetState(@SW_DISABLE, $guimain)

            Switch 1
                Case $Test
                    MsgBox(0, "", "Hello World!!!")
            EndSwitch

        Case $GUI_EVENT_CLOSE
            Switch $nMsg[1]
                Case $Child1
                    GUISetState(@SW_HIDE, $Child1)
                    GUISetState(@SW_ENABLE, $guimain)
                Case $guimain
                    Exit
            EndSwitch

    EndSwitch

WEnd

 

2nd Attempt: "Test Button Working but Parent Window not closing"

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIListViewEx.au3>

$guimain = GUICreate("Form1", 960, 540, 150, 100, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_CLIPCHILDREN, $WS_TABSTOP))




Local $idFilemenu = GUICtrlCreateMenu("&File")
Local $idRunmenu = GUICtrlCreateMenu("&Edit")
Local $idViewmenu = GUICtrlCreateMenu("&View")
Local $sInput0 = GUICtrlCreateInput("", 900, 50, 50, 20)


$Child0 = GUICtrlCreateButton("Child", 900, 0, 50, 20)
$List1 = GUICtrlCreateListView("", 0, 0, 500, 500, BitOR(0x0200, 0x008), BitOR(0x00000020, 0x00000001))
_GUICtrlListView_AddColumn($List1, "Col1", 150, 2)
_GUICtrlListView_AddColumn($List1, "Col2", 500, 2)
_GUICtrlListView_AddColumn($List1, "Col3", 50, 2)
_GUICtrlListView_Scroll($List1, 10, 100)

GUISetState(@SW_SHOW, $guimain)

While 1

    $nMsg = GUIGetMsg(1)
    Switch $nMsg[0]
        Case $Child0
            Opt("GUIOnEventMode", 1)
            $Child1 = GUICreate("Child1", 401, 488, 192, 124)
            $sLabel = GUICtrlCreateLabel("", 24, 16, 73, 17)
            $sInput1 = GUICtrlCreateInput("", 112, 16, 265, 21)
            $CC = GUISetOnEvent($GUI_EVENT_CLOSE, "CloseChild")
            $Test = GUICtrlCreateButton("Test", 72, 392, 75, 25)
            GUICtrlSetOnEvent(-1, "Test")
            GUISetState(@SW_SHOW, $Child1)
            GUISetState(@SW_DISABLE, $guimain)

;~          Switch 1
;~              Case $Test
;~                  MsgBox(0, "", "Hello World!!!")
;~          EndSwitch

        Case $GUI_EVENT_CLOSE
            Switch $nMsg[1]
                Case $guimain
                    Exit
            EndSwitch

    EndSwitch

WEnd

Func Test()
    MsgBox(0, "", "Hello World!!!")
EndFunc   ;==>Test

Func CloseChild()
    Select
        Case @GUI_CtrlId = $GUI_EVENT_CLOSE
            GUISetState(@SW_HIDE, $Child1)
            GUISetState(@SW_ENABLE, $guimain)
    EndSelect
EndFunc   ;==>CloseChild

 

Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Share this post


Link to post
Share on other sites
water

As always: The help file and the wiki are your best friends ;) 

  • Like 2

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

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

×