Sign in to follow this  
Followers 0
MrCreatoR

$WS_EX_MDICHILD - How to create moveable child window with his parent?

5 posts in this topic

#1 ·  Posted (edited)

Hi all...

I am trying to create a child window, that must move with his parent (when the parent moved, the child must move with it)...

From the help file:

$WS_EX_MDICHILD -> Create a child window that will be moved with its parent.

(simulation of a MDI window maximize/minimize are not simulated).

I am trying like this:

#include <GuiConstants.au3>

$Gui = GuiCreate("Test", 300, 200)
$ChildGui = GuiCreate("Child test", 300, 200, -1, -1, -1, $WS_EX_MDICHILD, $Gui)

$ParentPosArr = WinGetPos($Gui)
WinMove($ChildGui, "", $ParentPosArr[0]+$ParentPosArr[2], $ParentPosArr[1])

GUISetState(@SW_SHOW, $Gui)
GUISetState(@SW_SHOW, $ChildGui)

While 1
    $Msg = GUIGetMsg(1)
    Select
        Case $Msg[1] = $Gui And $Msg[0] = -3
            Exit
    EndSelect
WEnd

But only what i get, is some strange "effect" - the window of parent gui is kind of copying itself, and the screen is filed with it's "tail"... (until we minimize or close the parent window)

How to get it work? (move child widow with parent without any strange "effects").

P.S

I know that it's possible to do it using WinMove/WinGetPos etc... but why it's wont work with this style? (it also will save to as many lines of code).

Edited by MsCreatoR

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites



The child is being moved alright, it's just the repaint that gets messed up for some reason.

Here's my lolsome solution:

#include <GuiConstants.au3>

$Gui = GuiCreate("Test", 300, 200)
$ChildGui = GuiCreate("Child test", 300, 200, -1, -1, -1, $WS_EX_MDICHILD, $Gui)

$ParentPosArr = WinGetPos($Gui)
WinMove($ChildGui, "", $ParentPosArr[0]+$ParentPosArr[2], $ParentPosArr[1])

GUISetState(@SW_SHOW, $Gui)
GUISetState(@SW_SHOW, $ChildGui)
GUIRegisterMsg(0x231, "On_WM_ENTERSIZEMOVE")
GUIRegisterMsg(0x232, "On_WM_EXITSIZEMOVE")

While 1
    $Msg = GUIGetMsg(1)
    Select
        Case $Msg[1] = $Gui And $Msg[0] = -3
            Exit
    EndSelect
WEnd
Func On_WM_ENTERSIZEMOVE()
    WinSetTrans($ChildGui, '', 254)
EndFunc
Func On_WM_EXITSIZEMOVE()
    WinSetTrans($ChildGui, '', 255)
EndFunc

There's a better way of doing it than this workaround, but I'm no GUI expert, so go from here on your own if you want.

Maybe WM_PAINT or something...


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

#include <GuiConstants.au3>

$Gui = GuiCreate("Test", 300, 200)
$ChildGui = GuiCreate("Child test", 300, 200, -1, -1, -1,-1, $Gui)

$ParentPosArr = WinGetPos($Gui)
WinMove($ChildGui, "", $ParentPosArr[0]+$ParentPosArr[2], $ParentPosArr[1])

GUISetState(@SW_SHOW, $Gui)
GUIRegisterMsg (0x0003,"Move")
GUISetState(@SW_SHOW, $ChildGui)
GUIRegisterMsg (0x0003,"Move")

While 1
    $Msg = GUIGetMsg(1)
    Select
        Case $Msg[1] = $Gui And $Msg[0] = -3
            Exit
    EndSelect
WEnd
func Move($hWndGUI)
    if $hWndGUI=$Gui then
        $ParentPosArr = WinGetPos($Gui)
        WinMove($ChildGui, "", $ParentPosArr[0]+$ParentPosArr[2], $ParentPosArr[1])
    Else
        $ChildPosArr = WinGetPos($ChildGui)
        WinMove($Gui, "", $ChildPosArr[0]-$ChildPosArr[2], $ChildPosArr[1])
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

Thanks guys for the solution, but what i can not understand, is why the style $WS_EX_MDICHILD not working as it suppouse to, maby i should report about it as possible bug? :whistle:


Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

AutoIt is simple, subtle, elegant. © AutoIt Team

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