mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 19:39:18 +02:00
set constraints using wm_getminmaxinfo (issue #1520)
git-svn-id: trunk@8319 -
This commit is contained in:
parent
277243a09e
commit
b9c2988810
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user