Jump to content
Sign in to follow this  
spytek_98

How to Child window follow parent?

Recommended Posts

Hi all,

I have seen on the forum bits a pieces of examples on how to "glue" a child window to a parent window, so that it follows the parent around the screen. But I was hoping someone can give a full example algorithm ie dragging the child window to any side of the parent and it still follows the parent. Same idea as in Winamp and its playlist or DVDDecrypter with its log window.

Rather than me re-inventing the wheel, I was hoping that someone out there as already worked it out for me :)

Thanks in advance

Share this post


Link to post
Share on other sites

I created those scripts. I may be able to help, in a bit i might be able to post a function for you.


[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

Here you are

#include <GUIConstants.au3>
Global Const $CF_TOP = 0
Global Const $CF_LEFT = 1
Global Const $CF_RIGHT = 2
Global Const $CF_BOTTOM = 3
Opt ( "GUIOnEventMode", 1 )
GuiCreate("Child",400,80,350,300)
GUISetOnEvent ( $GUI_EVENT_CLOSE, "Quit" )
GUISetState ( )
GUICreate ( "Parent", 600, 400, -1, -1, $WS_SIZEBOX + $WS_SYSMENU )
GUISetOnEvent ( $GUI_EVENT_CLOSE, "Quit" )
GUISetState ( )

While 1
    _ChildFollow ( "Parent", "Child", $CF_BOTTOM )
WEnd

Func Quit()
    Exit
EndFunc

Func _ChildFollow ( $Parent, $Child, $ChildSide=0 )
    If $ChildSide=0 Then
        $PPos = WinGetPos ( $Child )
        $MovePos = WinGetPos ( $Parent )
        $X = ($MovePos[2]-$PPos[2])/2+$MovePos[0]
        WinMove ( $Child, "", $X , $MovePos[1] - ($PPos[3]-1) )
    ElseIf $ChildSide=1 Then
        $PPos = WinGetPos ( $Child )
        $MovePos = WinGetPos ( $Parent )
        $Y = ($MovePos[3]-$PPos[3])/2+$MovePos[1]
        WinMove ( $Child, "", $MovePos[0]-$PPos[2] , $Y )
    ElseIf $ChildSide=2 Then
        $PPos = WinGetPos ( $Child )
        $MovePos = WinGetPos ( $Parent )
        $Y = ($MovePos[3]-$PPos[3])/2+$MovePos[1]
        WinMove ( $Child, "", $MovePos[0]+$MovePos[2] , $Y )
    ElseIf $ChildSide=3 Then
        $PPos = WinGetPos ( $Child )
        $MovePos = WinGetPos ( $Parent )
        $X = ($MovePos[2]-$PPos[2])/2+$MovePos[0]
        WinMove ( $Child, "", $X , $MovePos[3] + $MovePos[1] )
    EndIf
EndFunc

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...