;=============================================================================== ; ; Function Name: _ResizeCtrl($hWnd, $hCtrl, $aSzWnd, $aSzCtrl) ; Description:: Move a Control after Resize in relative position to the window there is in ; Parameter(s): $hWnd - Handle/ID main-window ; $hCtrl - Handle/ID control to move ; $aSzWnd - Array with start size of window; $ar[4] = [X position, Y position, Width, Height] ; $aSzCtrl - Array with start size of control; $ar[4] = [X position, Y position, Width, Height] ; Requirement(s): $GUI_EVENT_RESIZED (get with GUIGetMsg() or in OnEvent-Mode: GUISetOnEvent($GUI_EVENT_RESIZED, 'Func') ; Note for OnEventMode: ; You need a function that calls _ResizeCtrl() because GUISetOnEvent allows no parameters. ; Return Value(s): on Success - 1 ; on Failure - 0 and set @error ; @error = 1 window not found ; @error = 2 control not found ; @error = 3 array for size window or control not given ; Author(s): BugFix (bugfix@autoit.de) ; ;=============================================================================== Func _ResizeCtrl($hWnd, $hCtrl, $aSzWnd, $aSzCtrl) Local $WinSize = WinGetPos($hWnd) If @error Then Return SetError(1) If ControlGetHandle($hWnd, '', $hCtrl) = '' Then Return SetError(2) If (Not IsArray($aSzWnd)) Or (Not IsArray($aSzCtrl)) Then Return SetError(3) Local $saveMode = Opt('GUICoordMode',1) Local $newWidth = Round($WinSize[2]*($aSzCtrl[2]/$aSzWnd[2])) Local $newHeight = Round($WinSize[3]*($aSzCtrl[3]/$aSzWnd[3])) Local $newX = Round($WinSize[2]*($aSzCtrl[0]/$aSzWnd[2])) Local $newY = Round($WinSize[3]*($aSzCtrl[1]/$aSzWnd[3])) ControlMove($hWnd, '', $hCtrl, $newX, $newY, $newWidth, $newHeight) Opt('GUICoordMode',$saveMode) Return 1 EndFunc ;==>_ResizeCtrl