Terenz

[SOLVED] Popup child inside Parent

6 posts in this topic

#1 ·  Posted (edited)

The code

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

Global $hGUI = GUICreate("TEST", 300, 300, -1, -1, $WS_SIZEBOX + $WS_MAXIMIZEBOX + $WS_MINIMIZEBOX)
Global $aGUI = WinGetClientSize($hGUI)
If @error Or Not IsArray($aGUI) Then Exit

Global $hChild = GUICreate("", $aGUI[0], $aGUI[1], 0, 0, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0xFF0000, $hChild)

GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hChild)

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUIDelete($hGUI)
                    GUIDelete($hChild)
                    Exit
            EndSwitch
    EndSwitch
WEnd

The result:

8xsac8.png

As you can see is not aligned or is the same size of the inside of the parent gui, the expected result. How to solve? After solved that, the second part is resize the child if the parent is resized. Thanks

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Share this post


Link to post
Share on other sites



Terenz,

I have seen this before with resizable GUIs - it seems that the increased border size interferes with the child GUI location. I will look into it and see if I can come up with a work-a-round.

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

Terenz,

Here you go:

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

$hGUI = GUICreate("TEST", 300, 300, Default, Default, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
GUISetBkColor(0x00FF00, $hGUI)
GUISetState(@SW_SHOW, $hGUI)

$iDiff = _WinAPI_GetSystemMetrics(7) - _WinAPI_GetSystemMetrics(32) ; Size frame - Fixed frame
$aGUI = WinGetClientSize($hGUI)

$hChild = GUICreate("", $aGUI[0], $aGUI[1], $iDiff, $iDiff, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
GUISetBkColor(0xFF0000, $hChild)
GUISetState(@SW_SHOW, $hChild)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

And note how you should combine styles - the Setting Styles tutorial in the Wiki explains why this is the case.

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

#4 ·  Posted (edited)

Does this fit:

 

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

Global $hGUI = GUICreate("TEST", 300, 300, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
Global $aGUI = WinGetClientSize($hGUI)
If @error Or Not IsArray($aGUI) Then Exit

Global $hChild = GUICreate("", $aGUI[0], $aGUI[1], 0, 0, $WS_CHILD, $WS_EX_MDICHILD)
GUISetBkColor(0xFF0000, $hChild)

GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hChild)

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUIRegisterMsg($WM_SIZE, "")
                    GUIDelete($hGUI)
                    GUIDelete($hChild)
                    Exit
            EndSwitch
    EndSwitch
WEnd

 

Or this one:

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

Global $iDelta = 10 ;just to show resizing
Global $hGUI = GUICreate("TEST", 300, 300, -1, -1, BitOR($WS_SIZEBOX, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX))
Global $aGUI = WinGetClientSize($hGUI)
If @error Or Not IsArray($aGUI) Then Exit
GUISetBkColor(0xFF00FF, $hGUI)
Global $hChild = GUICreate("test2", $aGUI[0] - $iDelta, $aGUI[1] - $iDelta, 0, 0, $WS_CHILD, -1, $hGUI)
GUISetBkColor(0xFF0000, $hChild)

GUISetState(@SW_SHOW, $hGUI)
GUISetState(@SW_SHOW, $hChild)

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

While 1
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hGUI
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE
                    GUIRegisterMsg($WM_SIZE, "")
                    GUIDelete($hGUI)
                    GUIDelete($hChild)
                    Exit
            EndSwitch
    EndSwitch
WEnd

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg, $wParam, $lParam
    Switch $hWnd
        Case $hGUI
            Local $tRect = _WinAPI_GetClientRect($hWnd)
            WinMove($hChild, "", $tRect.Left, $tRect.Top, _WinAPI_LoWord($lParam) - $iDelta, _WinAPI_HiWord($lParam) - $iDelta)
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

Modified the WM_SIZE code from InunoTaishou (next post)!

Edited by UEZ
Added 2nd version

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Looks like it's been solved already but I figured I'd throw this out there. Since you're going to be working with resizable GUI's, and only the main one is going to be resized (at least in the example given), check out the WM_SIZE message for keeping the child in the client area

GUIRegisterMsg($WM_SIZE, "WM_SIZE")

Func WM_SIZE($hWndFrom, $iMsg, $wParam, $lParam)
    #forceref $hWndFrom, $iMsg, $wParam, $lParam
    Local $iWidth = _WinAPI_LoWord($lParam)
    Local $iHeight = _WinAPI_HiWord($lParam)
    Local $tRect = _WinAPI_GetClientRect($hWndFrom)
    
    If ($hWndFrom = $hGUI) Then
        _WinAPI_ClientToScreen($hWndFrom, $tRect)
        WinMove($hChild, "", DllStructGetData($tRect, "Left"), DllStructGetData($tRect, "Top"), $iWidth, $iHeight)
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE

This just resizes the child to always fit the size of the parent but you can use it to resize the child when the main is too big or too small.

Edited by InunoTaishou

Share this post


Link to post
Share on other sites

Thanks guys, is all clear now ;)


Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

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