Jump to content

Recommended Posts

the second child gui window doesn't have the ex style $WS_EX_MDICHILD but it is moved with the parent gui. How can I make the second window not move and still be a child window?

 

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <String.au3>
#include <Array.au3>

$hParent = GUICreate("Parent", 500, 300)
$hChild1 = GUICreate("Child1", 200, 100, -1, -1, -1, $WS_EX_MDICHILD, $hParent)
$hChild2 = GUICreate("Child2", 200, 100, 100, -1, -1, -1, $hParent)
GUISetState(@SW_SHOW, $hParent)
GUISetState(@SW_SHOW, $hChild1)
GUISetState(@SW_SHOW, $hChild2)

While 1
    Sleep(10)
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

 

Edited by bladem2003
Link to post
Share on other sites

Don't use the $WS_EX_MDICHILD Extended Style in any childgui of $hParent and handle the moving yourself with with ControlGetPos, ControlMove.

Don't know it's a bug (one 1 MDIChild causes all Childs are MDIChilds) ore a feature.

Edited by AutoBert
Link to post
Share on other sites

Setting Child2 to Child1 instead of Parent1 seems to do what you want.

#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <String.au3>
#include <Array.au3>

$hParent = GUICreate("Parent", 500, 300)
$hChild1 = GUICreate("Child1", 200, 100, -1, -1, -1, $WS_EX_MDICHILD, $hParent)
$hChild2 = GUICreate("Child2", 200, 100, 100, -1, -1, -1, $hChild1)
GUISetState(@SW_SHOW, $hParent)
GUISetState(@SW_SHOW, $hChild1)
GUISetState(@SW_SHOW, $hChild2)

While 1
    Sleep(10)
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
WEnd

 

Some guy's script + some other guy's script = my script!

Link to post
Share on other sites

@Werty the problem when using your script is that minimizing child1 automatically minimizes child2 (if I'm not mistaken)

Back to 2015, Yashied wrote in this link :

If you read about the MDI windows in MSDN, it becomes clear that the work with these windows is slightly different from the standard windows. I'm not sure what it's all natively supported in AutoIt.

AutoIt help file stipulates :

$WS_EX_MDICHILD    Create a child window that will be moved with its parent (simulation of a MDI window maximize/minimize are not simulated).

But this is very far from a real MDI interface as shown in this msdn pic...

1459512439_Microsoft-MDIAPPLICATION-csmdi-01.PNG.bf89c639ca13d7b88d600dd1218420a7.PNG

... where 3 type of windows are involved :

1) a Frame window (initial GUI)
2) a MDI client window, which is displayed in the client area of the frame window. This MDI client window is a child of the frame window.
3) Child windows whose parent is the MDI client window. These child windows have a WS_EX_MDICHILD extended style.

As read on msdn : 

Many new and intermediate users find it difficult to learn to use MDI applications. Therefore, you should consider other models for your user interface.

Maybe that's why developers just picked the extended style $WS_EX_MDICHILD, only to allow "a window to be moved with its parent", but we can see the side effect in OP's script, where his $hChild2 moves when not requested, though it doesn't have a $WS_EX_MDICHILD extended style.

Edited by pixelsearch
typo
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...