diff --git a/lcl/interfaces/win32/win32callback.inc b/lcl/interfaces/win32/win32callback.inc index 0735304087..d640aea567 100644 --- a/lcl/interfaces/win32/win32callback.inc +++ b/lcl/interfaces/win32/win32callback.inc @@ -727,6 +727,32 @@ Var Windows.SendMessage(spinHandle, UDM_SETPOS32, 0, 500); WindowInfo^.spinValue := newValue; end; + + procedure SetMinMaxInfo(var MinMaxInfo: TMINMAXINFO); + procedure SetWin32SizePoint(AWidth, AHeight: integer; var pt: TPoint); + var + IntfWidth, IntfHeight: integer; + begin + // 0 means no constraint + if (AWidth=0) and (AHeight=0) then exit; + + IntfWidth := AWidth; + IntfHeight := AHeight; + LCLFormSizeToWin32Size(TCustomForm(lWinControl), IntfWidth, IntfHeight); + + if AWidth>0 then + pt.X:= IntfWidth; + if AHeight>0 then + pt.Y := IntfHeight; + end; + begin + if (lWinControl=nil) or not (lWinControl is TCustomForm) then exit; + with lWinControl.Constraints do begin + SetWin32SizePoint(MinWidth, MinHeight, MinMaxInfo.ptMinTrackSize); + SetWin32SizePoint(MaxWidth, MaxHeight, MinMaxInfo.ptMaxSize); + SetWin32SizePoint(MaxWidth, MaxHeight, MinMaxInfo.ptMaxTrackSize); + end; + end; Begin Assert(False, 'Trace:WindowProc - Start'); @@ -1142,6 +1168,10 @@ Begin end; end; } + WM_GETMINMAXINFO: + begin + SetMinMaxInfo(PMINMAXINFO(LParam)^); + end; WM_KEYDOWN: Begin NotifyUserInput := True; diff --git a/lcl/interfaces/win32/win32def.pp b/lcl/interfaces/win32/win32def.pp index d1098762ea..1aa324362c 100644 --- a/lcl/interfaces/win32/win32def.pp +++ b/lcl/interfaces/win32/win32def.pp @@ -37,6 +37,7 @@ Const MCM_FIRST = $1000; MCM_GETCURSEL = MCM_FIRST + 1; MCM_SETCURSEL = MCM_FIRST + 2; + MCM_GETMINREQRECT = MCM_FIRST + 9; Type TGDIType = (gdiBitmap, gdiBrush, gdiFont, gdiPen, gdiRegion); diff --git a/lcl/interfaces/win32/win32proc.pp b/lcl/interfaces/win32/win32proc.pp index 2d6b9c9e83..841f0f1d2d 100644 --- a/lcl/interfaces/win32/win32proc.pp +++ b/lcl/interfaces/win32/win32proc.pp @@ -27,7 +27,7 @@ unit win32proc; interface uses - Windows, Classes, LMessages, LCLType, LCLProc, Controls; + Windows, Classes, LMessages, LCLType, LCLProc, Controls, Forms; Type TEventType = (etNotify, etKey, etKeyPress, etMouseWheel, etMouseUpDown); @@ -82,12 +82,15 @@ function GetLCLClientBoundsOffset(Sender: TObject; var ORect: TRect): boolean; function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean; Procedure LCLBoundsToWin32Bounds(Sender: TObject; var Left, Top, Width, Height: Integer); +Procedure LCLFormSizeToWin32Size(Form: TCustomForm; var AWidth, AHeight: Integer); Procedure Win32PosToLCLPos(Sender: TObject; var Left, Top: SmallInt); procedure GetWin32ControlPos(Window, Parent: HWND; var Left, Top: integer); procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer); function BorderStyleToWin32Flags(Style: TFormBorderStyle): DWORD; function BorderStyleToWin32FlagsEx(Style: TFormBorderStyle): DWORD; +function GetDesigningBorderStyle(const AForm: TCustomForm): TFormBorderStyle; + function GetFileVersion(FileName: string): dword; function AllocWindowInfo(Window: HWND): PWindowInfo; function DisposeWindowInfo(Window: HWND): boolean; @@ -115,7 +118,7 @@ var implementation uses - SysUtils, LCLStrConsts, Menus, Dialogs, StdCtrls, ExtCtrls, Forms, + SysUtils, LCLStrConsts, Menus, Dialogs, StdCtrls, ExtCtrls, LCLIntf; //remove this unit when GetWindowSize is moved to TWSWinControl {$IFOPT C-} @@ -858,6 +861,26 @@ Begin inc(Top, ORect.Top); End; +procedure LCLFormSizeToWin32Size(Form: TCustomForm; var AWidth, AHeight: Integer); +{$NOTE Should be moved to WSWin32Forms, if the windowproc is splitted} +var + SizeRect: Windows.RECT; + BorderStyle: TFormBorderStyle; +begin + with SizeRect do + begin + Left := 0; + Top := 0; + Right := AWidth; + Bottom := AHeight; + end; + BorderStyle := GetDesigningBorderStyle(Form); + Windows.AdjustWindowRectEx(@SizeRect, BorderStyleToWin32Flags( + BorderStyle), false, BorderStyleToWin32FlagsEx(BorderStyle)); + AWidth := SizeRect.Right - SizeRect.Left; + AHeight := SizeRect.Bottom - SizeRect.Top; +end; + Procedure Win32PosToLCLPos(Sender: TObject; var Left, Top: SmallInt); var ORect: TRect; @@ -922,6 +945,15 @@ begin end; end; +function GetDesigningBorderStyle(const AForm: TCustomForm): TFormBorderStyle; +{$NOTE Belongs in Win32WSForms, but is needed in windowproc} +begin + if csDesigning in AForm.ComponentState then + Result := bsSizeable + else + Result := AForm.BorderStyle; +end; + function GetFileVersion(FileName: string): dword; var buf: pointer; diff --git a/lcl/interfaces/win32/win32wscalendar.pp b/lcl/interfaces/win32/win32wscalendar.pp index 7a38141bd8..8c6e9f5b5a 100644 --- a/lcl/interfaces/win32/win32wscalendar.pp +++ b/lcl/interfaces/win32/win32wscalendar.pp @@ -85,11 +85,6 @@ begin SetBounds(AWinControl, Params.Left, Params.Top, 0, 0); end; -const - // TODO: needs to move - MCM_FIRST = $1000; - MCM_GETMINREQRECT = MCM_FIRST + 9; - procedure TWin32WSCustomCalendar.AdaptBounds(const AWinControl: TWinControl; var Left, Top, Width, Height: integer; var SuppressMove: boolean); var diff --git a/lcl/interfaces/win32/win32wsforms.pp b/lcl/interfaces/win32/win32wsforms.pp index 3fcb0db0e1..ad7db97e34 100644 --- a/lcl/interfaces/win32/win32wsforms.pp +++ b/lcl/interfaces/win32/win32wsforms.pp @@ -172,14 +172,6 @@ end; { TWin32WSCustomForm } -function GetDesigningBorderStyle(const AForm: TCustomForm): TFormBorderStyle; -begin - if csDesigning in AForm.ComponentState then - Result := bsSizeable - else - Result := AForm.BorderStyle; -end; - function CalcBorderIconsFlags(const AForm: TCustomForm): dword; var BorderIcons: TBorderIcons;