Jump to content

Help, GUI Parent & Child Script


Recommended Posts

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.

Link to comment
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...