Jump to content

Recommended Posts

Posted

I know that this is somewhat unusual. I also understand that MDI (WS_EX_MDICHILD) windows are intended to move with the parent GUI window, not a child window (WS_CHILD).

However, for the sake of learning and trying unusual things, here we are...

From the example, you will notice that if you move the GUI around the screen, the pink-ish square (MDI window) stays in the middle and does not move with the GUI. That is because I have associated it with the white square which is a child window (WS_CHILD).

The first part of what I want to achieve is to synchronize the movement of the MDI window with the movement of the white child window, specifically.

The second part of what I would like to achieve would be to also synchronize the sizing of MDI window.

I am still very much a rookie when it comes to WM_SIZE and WM_MOVE which I am assuming would be required here.

Anyway, if anyone has a moment and is willing to assist with this, I would appreciate it very much. Thank you. :)

#include <WindowsStylesConstants.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 400, 400)
    GUISetBkColor(0x202020)



    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    $hChild = GUICreate("ChildWindow", 200, 200, 100, 100, 0x40000000, -1, $hGUI)
    GUISetBkColor(0xffffff)
    GUISetState(@SW_SHOW, $hChild)

    $hChildMDI = GUICreate("", 100, 100, 5, 5, $WS_POPUP, $WS_EX_MDICHILD, $hChild)
    GUISetBkColor(0xff00ff)
    GUISetState(@SW_SHOW, $hChildMDI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

 

Posted

Unless there is a specific reason to mix $WS_CHILD and $WS_EX_MDICHILD, you shouldn't do that.  All you will get out of it is useless complexity.  Now if you want to adapt the child windows to the size of its parent, here one easy way :

; From Nine
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

Opt("MustDeclareVars", True)

Global $hChild1, $hChild2, $aPosGUI

Example()

Func Example()
  Local $hGUI = GUICreate("Example", 400, 400, Default, Default, $WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED)
  GUISetBkColor(0x202020)
  GUISetState()

  $hChild1 = GUICreate("", 200, 200, 100, 100, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)
  GUISetBkColor(0xFFFFFF)
  GUISetState()

  $hChild2 = GUICreate("", 100, 100, 5, 5, $WS_POPUP, $WS_EX_MDICHILD, $hChild1)
  GUISetBkColor(0xFF00FF)
  GUISetState()

  GUIRegisterMsg($WM_SIZE, WM_SIZE)
  $aPosGUI = WinGetPos($hGUI)

  While True
    Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
  WEnd
EndFunc   ;==>Example

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
  Local $aPos = WinGetPos($hWnd), $aChild1 = WinGetPos($hChild1), $aChild2 = WinGetPos($hChild2)
  WinMove($hChild1, "", $aChild1[0], $aChild1[1], $aChild1[2] + $aPos[2] - $aPosGUI[2], $aChild1[3] + $aPos[3] - $aPosGUI[3])
  WinMove($hChild2, "", $aChild2[0], $aChild2[1], $aChild2[2] + $aPos[2] - $aPosGUI[2], $aChild2[3] + $aPos[3] - $aPosGUI[3])
  $aPosGUI = $aPos
EndFunc   ;==>WM_SIZE

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...