Sign in to follow this  
Followers 0
d0n

child gui in window

6 posts in this topic

#1 ·  Posted (edited)

is it possible to do this with the handle of a window?

right now i have an edit box, i am cutting that in half using controlmove and using the extra space for a child window. however i can only create the child gui within that control. and once i move the control, i can no longer see my child window

Existing control

|-----|
|XXXXX|
|XXXXX|
|-----|

trim existing control + adding child gui under it

|-----|
|XXXXX|
|-----|
|YYYYY|
Edited by d0n

Share this post


Link to post
Share on other sites



d0n,

Is this what you want to do?

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

Global Const $WM_ENTERSIZEMOVE = 0x231
Global $aRelPos[2]

$hGUI = GUICreate("Test", 500, 500, 200, 200)

$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 430)

$hButton = GUICtrlCreateButton("Show GUI", 10, 450, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            If GUICtrlRead($hButton) = "Show GUI" Then
                ControlMove($hGUI, "", $hEdit, 10, 10, 480, 230)

                $hChild = GUICreate("", 480, 200, 210, 470, $WS_POPUP, -1, $hGUI)
                GUISetBkColor(0xFFFF00, $hChild)
                GUISetState()

                GUIRegisterMsg($WM_ENTERSIZEMOVE, "_GetRelPos")
                GUIRegisterMsg($WM_MOVE, "_FollowMe")

                GUICtrlSetData($hButton, "Hide GUI")
            Else
                GUIRegisterMsg($WM_ENTERSIZEMOVE, "")
                GUIRegisterMsg($WM_MOVE, "")

                GUIDelete($hChild)

                ControlMove($hGUI, "", $hEdit, 10, 10, 480, 430)

                GUICtrlSetData($hButton, "Show GUI")
            EndIf

    EndSwitch

WEnd

; Credit to martin for these functions

Func _FollowMe($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    If $hWnd <> $hGUI Then Return

    Local $aGUI_Pos = WinGetPos($hGUI) ; Use WinGetPos and not $lParam values
    WinMove($hChild, "", $aGUI_Pos[0] - $aRelPos[0], $aGUI_Pos[1] - $aRelPos[1])

EndFunc ;==>_FollowMe


;When the primary window starts moving get the relative position of the secondary window.
Func _GetRelPos($hWnd, $iMsg, $wParam, $lParam)

    #forceref $iMsg, $wParam, $lParam

    If $hWnd <> $hGUI Then Return

    Local $aGUI_Pos = WinGetPos($hGUI)
    Local $aChild_Pos = WinGetPos($hChild)

    $aRelPos[0] = $aGUI_Pos[0] - $aChild_Pos[0]
    $aRelPos[1] = $aGUI_Pos[1] - $aChild_Pos[1]

EndFunc ;==>_GetRelPos

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

That guy martin has some funny ideas. His functions can be replaced by one line.

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

Global Const $WM_ENTERSIZEMOVE = 0x231
Global $aRelPos[2]

$hGUI = GUICreate("Test", 500, 500, 200, 200)

$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 430)

$hButton = GUICtrlCreateButton("Show GUI", 10, 450, 80, 30)

GUISetState()

While 1

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    Case $hButton
    If GUICtrlRead($hButton) = "Show GUI" Then
    ControlMove($hGUI, "", $hEdit, 10, 10, 480, 230)

    $hChild = GUICreate("", 480, 200, 10, 250, $WS_POPUP, -1);, $hGUI)
                DllCall("user32.dll", "int", "SetParent", "hwnd", $hChild, "hwnd", $hGUI)
    GUISetBkColor(0xFFFF00, $hChild)
    GUISetState()

    GUICtrlSetData($hButton, "Hide GUI")
    Else

    GUIDelete($hChild)

    ControlMove($hGUI, "", $hEdit, 10, 10, 480, 430)

    GUICtrlSetData($hButton, "Show GUI")
    EndIf

    EndSwitch

WEnd

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

martin,

Funny, yes - but very useful. :) Thanks for the corrected version - another tool to add to the snippets store.

Of interest, the 2-function version came from this post of yours from about a week ago - although that did not use a child window.

M23

Edit: There is actually a function for that DLL call in the WinAPI UDF:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

$hGUI = GUICreate("Test", 500, 500, 200, 200)
$hEdit = GUICtrlCreateEdit("", 10, 10, 480, 430)
$hButton = GUICtrlCreateButton("Show GUI", 10, 450, 80, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            If GUICtrlRead($hButton) = "Show GUI" Then
                ControlMove($hGUI, "", $hEdit, 10, 10, 480, 230)
                $hChild = GUICreate("", 480, 200, 10, 250, $WS_POPUP)
                _WinAPI_SetParent($hChild, $hGUI)
                GUISetBkColor(0xFFFF00, $hChild)
                GUISetState()
                GUICtrlSetData($hButton, "Hide GUI")
            Else
                GUIDelete($hChild)
                ControlMove($hGUI, "", $hEdit, 10, 10, 480, 430)
                GUICtrlSetData($hButton, "Show GUI")
            EndIf
    EndSwitch
WEnd
Edited by Melba23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

It kinda works after i edit it into my script, but sometimes it would just flicker and no child window would appear

$Pos = ControlGetPos($Title, "", "[CLASS:RichEdit20A; INSTANCE:2]")
GUICreate("Test", 80, 60)
$Button1 = GUICtrlCreateButton("Start", 14,8, 50, 20)
$Button2 = GUICtrlCreateButton("Stop", 14,30, 50, 20)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Button1 Then Start()
    If $msg = $Button2 Then Stop()
WEnd

Func Start()

    ControlMove($Title, "", "[CLASS:RichEdit20A; INSTANCE:2]", $Pos[0]+100, $Pos[1], $Pos[2], $Pos[3]/2)
    $Chat1 = GUICreate("",$Pos[2],$Pos[3]/2,$Pos[0],$Pos[3]/2, BitOR($WS_Popup,$WS_Overlapped,$DS_SETFOREGROUND))
    _WinAPI_SetParent($Chat1, 0x000403AA)
    GUISetBkColor(0xFFFF00, $Chat1)
    GUISetState(@SW_SHOW, $Chat1)

EndFunc

Func Stop()

    GUIDelete($Chat1)
    ControlMove($Title, "", "[CLASS:RichEdit20A; INSTANCE:2]", $Pos[0], $Pos[1], $Pos[2], 595)

EndFunc

EDIT: It works if i keep clicking start, and hope the gui appears, then it will stay there lol

EDIT: Seems to of fixed it by adding Sleep :)

Thanks for the help guys

Edited by d0n

Share this post


Link to post
Share on other sites

It kinda works after i edit it into my script, but sometimes it would just flicker and no child window would appear

$Pos = ControlGetPos($Title, "", "[CLASS:RichEdit20A; INSTANCE:2]")
GUICreate("Test", 80, 60)
$Button1 = GUICtrlCreateButton("Start", 14,8, 50, 20)
$Button2 = GUICtrlCreateButton("Stop", 14,30, 50, 20)
GUISetState(@SW_SHOW)

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    If $msg = $Button1 Then Start()
    If $msg = $Button2 Then Stop()
WEnd

Func Start()

    ControlMove($Title, "", "[CLASS:RichEdit20A; INSTANCE:2]", $Pos[0]+100, $Pos[1], $Pos[2], $Pos[3]/2)
    $Chat1 = GUICreate("",$Pos[2],$Pos[3]/2,$Pos[0],$Pos[3]/2, BitOR($WS_Popup,$WS_Overlapped,$DS_SETFOREGROUND))
    _WinAPI_SetParent($Chat1, 0x000403AA)
    GUISetBkColor(0xFFFF00, $Chat1)
    GUISetState(@SW_SHOW, $Chat1)

EndFunc

Func Stop()

    GUIDelete($Chat1)
    ControlMove($Title, "", "[CLASS:RichEdit20A; INSTANCE:2]", $Pos[0], $Pos[1], $Pos[2], 595)

EndFunc

EDIT: It works if i keep clicking start, and hope the gui appears, then it will stay there lol

EDIT: Seems to of fixed it by adding Sleep :)

Thanks for the help guys

No idea, but where does 0x0004003A come from?

Looks like these two lines

$Chat1 = GUICreate("",$Pos[2],$Pos[3]/2,$Pos[0],$Pos[3]/2, BitOR($WS_Popup,$WS_Overlapped,$DS_SETFOREGROUND))
    _WinAPI_SetParent($Chat1, 0x000403AA)

should be

$Chat1 = GUICreate("",$Pos[2],$Pos[3]/2,$Pos[0],$Pos[1] + $Pos[3]/2, BitOR($WS_Popup,$WS_Overlapped,$DS_SETFOREGROUND))
    _WinAPI_SetParent($Chat1, WinGetHandle($sTitle))

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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
Sign in to follow this  
Followers 0