﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2549	Window controls do not always relocate with GUICtrlSetPos	john@…		"The program below creates a resizable window. When the window is resized all of the controls move to new positions (not a good thing) so I have a function _Display() which uses GUICtrlSetPos to set the controls back to their original positions. This works for all controls I have tested - except for buttons. With buttons the left and top positions have to be different from those specified in the original GUICtrlCreate for the GUICtrlSetPos to work. You can see this where the Yes and No buttons have the same values as the original but the Exit button has slightly different values. Note also that if the commented out _Display() function in line 22 is called none of the buttons is relocated.



{{{
; John - 2 Dec 2013 First test program
; A simple custom messagebox that uses the MessageLoop mode


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
Global $YesID, $NoID, $ExitID, $msg, $winWidth, $winHeight, $hwnd, $LabID, $WidthID, $HeightID, $CBID
$winWidth = 400
$winHeight = 300

$hwnd = GUICreate(""John - Custom Msgbox"", $winWidth, $winHeight, -1, -1, $WS_SIZEBOX) ; can be resized
$LabID = GUICtrlCreateLabel(""Please click a button!"", 10, 10)
$YesID = GUICtrlCreateButton(""Yes"", 10, 50, 50, 20)
$NoID = GUICtrlCreateButton(""No"", 80, 50, 50, 20)
$ExitID = GUICtrlCreateButton(""Exit"", 151, 51, 50, 20)
$WidthID = GUICtrlCreateLabel(""Width = "" & $winWidth, 10, 100)
$HeightID = GUICtrlCreateLabel(""Height = "" & $winHeight, 100, 100)
$CBID = GUICtrlCreateCheckbox(""test"", 10, 150)
GUISetState(@SW_SHOWNORMAL, $hwnd) ; display the GUI

;_Display()
Do
	$msg = GUIGetMsg($hwnd)
	If $msg = $GUI_EVENT_RESIZED Then _Display()
Until $msg = $GUI_EVENT_CLOSE Or $msg = $ExitID

Func _Display()
	$winWidth = _WinAPI_GetClientWidth($hwnd)
	$winHeight = _WinAPI_GetClientHeight($hwnd)
	GUICtrlSetPos($LabID, 10, 10)
	GUICtrlSetPos($YesID, 10, 50, 50, 20)
	GUICtrlSetPos($NoID, 80, 50, 50, 20)
	GUICtrlSetPos($ExitID, 150, 50, 50, 20)
	GUICtrlSetData($WidthID, ""Width = "" & $winWidth)
	GUICtrlSetData($HeightID, ""Height = "" & $winHeight)
	GUICtrlSetPos($WidthID, 10, 100)
	GUICtrlSetPos($HeightID, 100, 100)
	GUICtrlSetPos($CBID, 10, 150)
EndFunc
}}}"	Bug	closed		AutoIt	3.3.8.1	None	No Bug	GUICtrlCreate GUICtrlSetPos	
