zcoacoaz 0 Posted April 20, 2005 (edited) Here is _ChildFollow Global Const $CF_TOP = 0 Global Const $CF_LEFT = 1 Global Const $CF_RIGHT = 2 Global Const $CF_BOTTOM = 3 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 And here is the _ChildFollow example expandcollapse popup#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 Here is the bigger _ChildFollow example expandcollapse popup#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 ( ) GUICreate ( "Second Child", 80, 200 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "Quit" ) GUISetState ( ) GUICreate ( "Third Child", 80, 200 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "Quit" ) GUISetState ( ) GUICreate ( "Forth Child", 400, 80 ) GUISetOnEvent ( $GUI_EVENT_CLOSE, "Quit" ) GUISetState ( ) While 1 _ChildFollow ( "Parent", "Child", $CF_BOTTOM ) _ChildFollow ( "Parent", "Second Child", $CF_LEFT ) _ChildFollow ( "Parent", "Third Child", $CF_RIGHT ) _ChildFollow ( "Parent", "Forth Child", $CF_TOP ) 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 Edited April 20, 2005 by Xenogis [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
steveR 0 Posted April 21, 2005 Holy windows, batman! Could be useful, Thanks! AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass. Share this post Link to post Share on other sites
buzz44 1 Posted April 21, 2005 (edited) Nice, to bad it doesn't move in 'real time', ie. The window changes position after you release the mouse button.Edit: Also, in your example you might want to make the 'Child' windows... child windows... eg.$Parent = GUICreate ( "Parent", 600, 400, -1, -1, $WS_SIZEBOX + $WS_SYSMENU ) GUICreate ( "First Child",400,80,350,300,-1,-1,$Parent ) GUICreate ( "Second Child", 80, 200-1,-1,$Parent ) GUICreate ( "Third Child", 80, 200-1,-1,$Parent ) GUICreate ( "Forth Child", 400, 80-1,-1,$Parent )So you only have 'one' window that appears in the taskbar and task manager etc. Just a suggestion. Edited April 21, 2005 by Burrup qq Share this post Link to post Share on other sites