Jump to content

GUI inside GUI


Alek
 Share

Recommended Posts

Search for SetParent. Holger had a post about a while back ago.

i found one example with DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child_gui), "hwnd", WinGetHandle($Main_gui))

but it dosent work in the way i want, i want to create a area inside a gui where i can put another gui,

and i want to be able to use buttons on the main gui and the other gui.

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Link to comment
Share on other sites

Hi,

something like this?

;Gui drumrun
#include <GUIConstants.au3>
#include <Array.au3>
HotKeySet("{ESC}", "_end")

Global $title = 'Unbenannt - Editor' ; German!!!

;ShellExecute('notepad', '', '', 'open', @SW_SHOW)
$PID = Run(@WindowsDir & "\notepad.exe", "", @SW_SHOW)
WinWait($title, '', 2)
$handle = WinGetHandle($title)
WinMove($handle, '', 100, 200, 400, 200)

Global $start = WinGetPos($handle)
$gui = GUICreate("GUI", $start[2] + 50, $start[3] + 50, $start[0] - 25, $start[1] - 55, Default)
$exit_B = GUICtrlCreateButton('Exit', 5, 1, 100, 20)
GUISetBkColor(0x00FF00)

WinSetTitle($handle, '', 'Megas Notepad :-)')

_GUICreateInvRect($gui, 20, 50, $start[2] + 10, $start[3] + 10)
GUISetState(@SW_SHOW)       ; will display an empty dialog box

;Variables

Global $saveGuipos = WinGetPos('GUI')

; Run the GUI until the dialog is closed
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            WinClose($handle)
            ExitLoop
        Case $exit_B
            WinClose($handle)
            ExitLoop
    EndSwitch
    _checkWin()
WEnd

Func _checkWin()
    $newGUIpos = WinGetPos('GUI')
    $p1 = _ArrayToString($saveGuipos, ',')
    $p2 = _ArrayToString($newGUIpos, ',')
    If $p1 <> $p2 Then
        ConsoleWrite(1 & @CRLF)
        WinMove($handle, '', $newGUIpos[0] + 25, $newGUIpos[1] + 55)
        $saveGuipos = $newGUIpos
    EndIf
EndFunc   ;==>_checkWin


Func _GUICreateInvRect($hwnd, $l, $t, $w, $h)
    $pos = WinGetPos($hwnd)
    $1 = 0
    $2 = 0
    $3 = $pos[2]
    $4 = $t
    $ret = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = 0
    $3 = $l
    $4 = $pos[3]
    $ret2 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = $l + $w
    $2 = 0
    $3 = $pos[2]
    $4 = $pos[3]
    $ret3 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)
    $1 = 0
    $2 = $t + $h
    $3 = $pos[2]
    $4 = $pos[3]
    $ret4 = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $1, "long", $2, "long", $3, "long", $4)

    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret2[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret3[0], "int", 2)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $ret[0], "long", $ret[0], "long", $ret4[0], "int", 2)

    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hwnd, "long", $ret[0], "int", 1)
EndFunc   ;==>_GUICreateInvRect

Func _end()
    Exit (0)
EndFunc   ;==>_end

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Seems like SetParent is what you need to do.

#include <GuiConstants.au3>
$Main_GUI = GUICreate("Main")
$Btn_Exit = GUICtrlCreateButton("E&xit", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Main_GUI)
$Child_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CAPTION)
GUISetBkColor(0xfffaf0, $Child_GUI)
$Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child_GUI)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child_GUI), "hwnd", WinGetHandle($Main_GUI))

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Btn_Exit
            Exit
        Case $Btn_Test
            MsgBox(0, "Test", "Hit Button on Child Window")
    EndSwitch
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Make it look a little more like your (ish)

#include <GuiConstants.au3>
$Main_GUI = GUICreate("Main", 500, 500)
GUISetBkColor(0xfffaf0, $Main_GUI)
GUISetState(@SW_SHOW, $Main_GUI)
$Child1_GUI = GUICreate("Child", 480, 480, 10, 10, $WS_CHILD, -1, $Main_GUI)
$Btn_Exit = GUICtrlCreateButton("E&xit", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child1_GUI)
$Child2_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CAPTION)
GUISetBkColor(0xfffaf0, $Child2_GUI)
$Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child2_GUI)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI))

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Btn_Exit
            Exit
        Case $Btn_Test
            MsgBox(0, "Test", "Hit Button on Child Window")
    EndSwitch
WEnd

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Make it look a little more like your (ish)

#include <GuiConstants.au3>
$Main_GUI = GUICreate("Main", 500, 500)
GUISetBkColor(0xfffaf0, $Main_GUI)
GUISetState(@SW_SHOW, $Main_GUI)
$Child1_GUI = GUICreate("Child", 480, 480, 10, 10, $WS_CHILD, -1, $Main_GUI)
$Btn_Exit = GUICtrlCreateButton("E&xit", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child1_GUI)
$Child2_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CAPTION)
GUISetBkColor(0xfffaf0, $Child2_GUI)
$Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child2_GUI)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI))

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Btn_Exit
            Exit
        Case $Btn_Test
            MsgBox(0, "Test", "Hit Button on Child Window")
    EndSwitch
WEnd
thats really clever.
Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()
Link to comment
Share on other sites

  • 9 years later...
On 15/05/2007 at 11:49 PM, GaryFrost said:

Make it look a little more like your (ish)

 

 

#include <GuiConstants.au3>
$Main_GUI = GUICreate("Main", 500, 500)
GUISetBkColor(0xfffaf0, $Main_GUI)
GUISetState(@SW_SHOW, $Main_GUI)
$Child1_GUI = GUICreate("Child", 480, 480, 10, 10, $WS_CHILD, -1, $Main_GUI)
$Btn_Exit = GUICtrlCreateButton("E&xit", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child1_GUI)
$Child2_GUI = GUICreate("Child", 200, 100, 10, 50, $WS_CAPTION)
GUISetBkColor(0xfffaf0, $Child2_GUI)
$Btn_Test = GUICtrlCreateButton("Test", 10, 10, 90, 20)
GUISetState(@SW_SHOW, $Child2_GUI)
DllCall("user32.dll", "int", "SetParent", "hwnd", WinGetHandle($Child2_GUI), "hwnd", WinGetHandle($Child1_GUI))

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Btn_Exit
            Exit
        Case $Btn_Test
            MsgBox(0, "Test", "Hit Button on Child Window")
    EndSwitch
WEnd

Great :) But how is child positioned in Main GUI?

Before the DLL call the child is placed outside of Main GUI.

I have the need to place several children inside the Main GUI so need to place accurately.

The most powerful number in the Universe.  Zero.

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...