From f2011b86d1cd7cadf6bc07759ea1ed5d74461940 Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Wed, 19 Aug 2009 22:05:40 +0000 Subject: [PATCH] Fixes spin control SetBounds in wince git-svn-id: trunk@21338 - --- lcl/interfaces/wince/wincewinapi.inc | 24 +++++++++++++++++++----- lcl/interfaces/wince/wincewscontrols.pp | 4 +++- lcl/interfaces/wince/wincewsspin.pp | 4 ++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lcl/interfaces/wince/wincewinapi.inc b/lcl/interfaces/wince/wincewinapi.inc index b62a245537..085aa16c09 100644 --- a/lcl/interfaces/wince/wincewinapi.inc +++ b/lcl/interfaces/wince/wincewinapi.inc @@ -1697,15 +1697,29 @@ var WindowInfo: PWindowInfo; Style, ExStyle: longint; -{ procedure AdjustForBuddySize; + procedure AdjustForBuddySize; + {$IFDEF WinCE} var BuddyHandle: HWND; - BuddyWP: WINDOWPLACEMENT; + BuddyR: TRect; begin + BuddyHandle := Windows.SendMessage(Handle, UDM_GETBUDDY, 0, 0); + if (BuddyHandle<>HWND(nil)) then + if Windows.GetWindowRect(BuddyHandle, BuddyR) then + Width := BuddyR.Right - BuddyR.Left; + end; + {$ELSE} + var + BuddyHandle: HWND; + BuddyWP, WP: WINDOWPLACEMENT; + begin + WP.length := SizeOf(WP); + Windows.GetWindowPlacement(Handle, WP); BuddyHandle := Windows.SendMessage(Handle, UDM_GETBUDDY, 0, 0); if (BuddyHandle<>HWND(nil)) and Windows.GetWindowPlacement(BuddyHandle, BuddyWP) then Width := WP.rcNormalPosition.Right - BuddyWP.rcNormalPosition.Left; - end;} + end; + {$ENDIF} begin Result := Boolean(Windows.GetWindowRect(Handle, R)); @@ -1760,8 +1774,8 @@ begin else Dec(Height, Windows.GetSystemMetrics(SM_CYCAPTION)); -// if (WindowInfo^.WinControl is TCustomFloatSpinEdit) then -// AdjustForBuddySize; + if (WindowInfo^.WinControl is TCustomFloatSpinEdit) then + AdjustForBuddySize; end; { diff --git a/lcl/interfaces/wince/wincewscontrols.pp b/lcl/interfaces/wince/wincewscontrols.pp index 431d589991..c296589218 100644 --- a/lcl/interfaces/wince/wincewscontrols.pp +++ b/lcl/interfaces/wince/wincewscontrols.pp @@ -409,7 +409,9 @@ begin {$ENDIF} suppressMove := false; AdaptBounds(AWinControl, IntfLeft, IntfTop, IntfWidth, IntfHeight, suppressMove); - MoveWindow(AWinControl.Handle, IntfLeft, IntfTop, IntfWidth, IntfHeight, true); + // Some controls, like spins, may set suppressMove in AdaptBounds + if not suppressMove then + MoveWindow(AWinControl.Handle, IntfLeft, IntfTop, IntfWidth, IntfHeight, true); LCLControlSizeNeedsUpdate(AWinControl, false); end; diff --git a/lcl/interfaces/wince/wincewsspin.pp b/lcl/interfaces/wince/wincewsspin.pp index 1a4669320a..67e6e77752 100644 --- a/lcl/interfaces/wince/wincewsspin.pp +++ b/lcl/interfaces/wince/wincewsspin.pp @@ -187,7 +187,7 @@ begin // Felipe: With this code, the edit part gets invisible // Is the same as win32 code, need to check why -{ WinHandle := AWinControl.Handle; + WinHandle := AWinControl.Handle; BuddyHandle := Windows.SendMessage(WinHandle, UDM_GETBUDDY, 0, 0); GetWindowRect(WinHandle, @R); @@ -196,7 +196,7 @@ begin MoveWindow(BuddyHandle, Left, Top, Width - WindowWidth + 2, Height, True); MoveWindow(WinHandle, Left + Width - WindowWidth, Top, WindowWidth, Height, True); - SuppressMove := True;} + SuppressMove := True; end; class function TWinCEWSCustomFloatSpinEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;