Jump to content

Recommended Posts

Posted (edited)

I came across and found out I need some GUI child win instead of msg box, so now I am wondering. How does child work exactly, I've search through help file and I did not find any clue, do you create another GUI and setstate as hidden? Or there is something else?

Thanks in advance.

:shocked:

Edit: I posted here because there are way less user browsing GUI forum, so insteading of keep bumping in there I posted it here.

Edited by Generator
Posted

Look in the help file at GuiCreate(). The function returns the handle of GUI being created. If you then create a second GUI while passing the handle from the first, you are creating a CHILD GUI.

Handy demo:

#include <guiconstants.au3>

Opt("GuiOnEventMode", 1)
$hGuiParent = GUICreate("Parent GUI", 200, 100, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUISetState()

$hGuiChild = GUICreate("Child GUI", 200, 100, 300, 300, -1, -1, $hGuiParent)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Warn")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func _Warn()
    MsgBox(16, "Warning", "You are closing the window.")
    GUIDelete($hGuiChild)
EndFunc

:shocked:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Posted

Look in the help file at GuiCreate(). The function returns the handle of GUI being created. If you then create a second GUI while passing the handle from the first, you are creating a CHILD GUI.

Handy demo:

#include <guiconstants.au3>

Opt("GuiOnEventMode", 1)
$hGuiParent = GUICreate("Parent GUI", 200, 100, 100, 100)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
GUISetState()

$hGuiChild = GUICreate("Child GUI", 200, 100, 300, 300, -1, -1, $hGuiParent)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Warn")
GUISetState()

While 1
    Sleep(20)
WEnd

Func _Quit()
    Exit
EndFunc

Func _Warn()
    MsgBox(16, "Warning", "You are closing the window.")
    GUIDelete($hGuiChild)
EndFunc

:shocked:

Thanks, really good example and easy to understand.
Posted (edited)

One more thing. I have a function that creates a child GUI of the main GUI. But if user activiates that function again, it creates and other child GUI which isn't what I wanted. And if so, I can close the new 1 but not the old 1, the old GUI child seems responseless. Anyidea how to fix this?

Thanks in Advance.

:shocked:

Edit: Problem Solved.

Edited by Generator

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
×
×
  • Create New...