Jump to content

Control element in child window


Melkor
 Share

Recommended Posts

I want to create second (child) window from Main (parent) window with control element (for example Button and List).

I can create second window, but there isn't control elemens.

Could help me anybody?

Best regards Nikita.

Luck, Love and PatienceNikita

Link to comment
Share on other sites

Not 100% sure what you mean, but something like this?

#include <GUIConstants.au3>

$gui_1 = GUICreate('Window 1', 200, 30, @DesktopWidth / 2 - 100, @DesktopHeight / 2 - 100)
$btn_1 = GUICtrlCreateButton('Button 1', 10, 10, 180, 20)

$gui_2 = GUICreate('Window 2', 200, 30)
$btn_2 = GUICtrlCreateButton('Button 2', 10, 10, 180, 20)

GUISetState(@SW_SHOW, $gui_1)
GUISetState(@SW_SHOW, $gui_2)

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn_1
            MsgBox(0, '', 'btn 1')
        Case $btn_2
            MsgBox(0, '', 'btn 2')
    EndSwitch
WEnd
Link to comment
Share on other sites

Would you like fries with that?

#include <GUIConstants.au3>

Opt('GUIOnEventMode', 1)

GUICreate('Window 1', 200, 30, @DesktopWidth / 2 - 100, @DesktopHeight / 2 - 100)
GUISetOnEvent($GUI_EVENT_CLOSE, 'quit')

$btn_1 = GUICtrlCreateButton('Button 1', 10, 10, 180, 20)
GUICtrlSetOnEvent($btn_1, 'gui2')

GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func gui2()
    If Not WinExists('Window 2') Then
        GUICreate('Window 2', 200, 30)
        GUISetOnEvent($GUI_EVENT_CLOSE, 'del')
        $btn_2 = GUICtrlCreateButton('Button 2', 10, 10, 180, 20)
        GUICtrlSetOnEvent($btn_2, 'btn2')
        GUISetState(@SW_SHOW)
    EndIf
EndFunc

Func btn2()
    MsgBox(0, '', 'btn2')
EndFunc

Func del()
    GUIDelete()
EndFunc

Func quit()
    Exit
EndFunc
Edited by xcal
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...