mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-11 20:39:15 +02:00
set constraints using wm_getminmaxinfo (issue #1520)
git-svn-id: trunk@8319 -
This commit is contained in:
parent
277243a09e
commit
b9c2988810
@ -728,6 +728,32 @@ Var
|
|||||||
WindowInfo^.spinValue := newValue;
|
WindowInfo^.spinValue := newValue;
|
||||||
end;
|
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
|
Begin
|
||||||
Assert(False, 'Trace:WindowProc - Start');
|
Assert(False, 'Trace:WindowProc - Start');
|
||||||
|
|
||||||
@ -1142,6 +1168,10 @@ Begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
}
|
}
|
||||||
|
WM_GETMINMAXINFO:
|
||||||
|
begin
|
||||||
|
SetMinMaxInfo(PMINMAXINFO(LParam)^);
|
||||||
|
end;
|
||||||
WM_KEYDOWN:
|
WM_KEYDOWN:
|
||||||
Begin
|
Begin
|
||||||
NotifyUserInput := True;
|
NotifyUserInput := True;
|
||||||
|
@ -37,6 +37,7 @@ Const
|
|||||||
MCM_FIRST = $1000;
|
MCM_FIRST = $1000;
|
||||||
MCM_GETCURSEL = MCM_FIRST + 1;
|
MCM_GETCURSEL = MCM_FIRST + 1;
|
||||||
MCM_SETCURSEL = MCM_FIRST + 2;
|
MCM_SETCURSEL = MCM_FIRST + 2;
|
||||||
|
MCM_GETMINREQRECT = MCM_FIRST + 9;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TGDIType = (gdiBitmap, gdiBrush, gdiFont, gdiPen, gdiRegion);
|
TGDIType = (gdiBitmap, gdiBrush, gdiFont, gdiPen, gdiRegion);
|
||||||
|
@ -27,7 +27,7 @@ unit win32proc;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Windows, Classes, LMessages, LCLType, LCLProc, Controls;
|
Windows, Classes, LMessages, LCLType, LCLProc, Controls, Forms;
|
||||||
|
|
||||||
Type
|
Type
|
||||||
TEventType = (etNotify, etKey, etKeyPress, etMouseWheel, etMouseUpDown);
|
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;
|
function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean;
|
||||||
Procedure LCLBoundsToWin32Bounds(Sender: TObject;
|
Procedure LCLBoundsToWin32Bounds(Sender: TObject;
|
||||||
var Left, Top, Width, Height: Integer);
|
var Left, Top, Width, Height: Integer);
|
||||||
|
Procedure LCLFormSizeToWin32Size(Form: TCustomForm; var AWidth, AHeight: Integer);
|
||||||
Procedure Win32PosToLCLPos(Sender: TObject; var Left, Top: SmallInt);
|
Procedure Win32PosToLCLPos(Sender: TObject; var Left, Top: SmallInt);
|
||||||
procedure GetWin32ControlPos(Window, Parent: HWND; var Left, Top: integer);
|
procedure GetWin32ControlPos(Window, Parent: HWND; var Left, Top: integer);
|
||||||
|
|
||||||
procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer);
|
procedure UpdateWindowStyle(Handle: HWnd; Style: integer; StyleMask: integer);
|
||||||
function BorderStyleToWin32Flags(Style: TFormBorderStyle): DWORD;
|
function BorderStyleToWin32Flags(Style: TFormBorderStyle): DWORD;
|
||||||
function BorderStyleToWin32FlagsEx(Style: TFormBorderStyle): DWORD;
|
function BorderStyleToWin32FlagsEx(Style: TFormBorderStyle): DWORD;
|
||||||
|
function GetDesigningBorderStyle(const AForm: TCustomForm): TFormBorderStyle;
|
||||||
|
|
||||||
function GetFileVersion(FileName: string): dword;
|
function GetFileVersion(FileName: string): dword;
|
||||||
function AllocWindowInfo(Window: HWND): PWindowInfo;
|
function AllocWindowInfo(Window: HWND): PWindowInfo;
|
||||||
function DisposeWindowInfo(Window: HWND): boolean;
|
function DisposeWindowInfo(Window: HWND): boolean;
|
||||||
@ -115,7 +118,7 @@ var
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
SysUtils, LCLStrConsts, Menus, Dialogs, StdCtrls, ExtCtrls, Forms,
|
SysUtils, LCLStrConsts, Menus, Dialogs, StdCtrls, ExtCtrls,
|
||||||
LCLIntf; //remove this unit when GetWindowSize is moved to TWSWinControl
|
LCLIntf; //remove this unit when GetWindowSize is moved to TWSWinControl
|
||||||
|
|
||||||
{$IFOPT C-}
|
{$IFOPT C-}
|
||||||
@ -858,6 +861,26 @@ Begin
|
|||||||
inc(Top, ORect.Top);
|
inc(Top, ORect.Top);
|
||||||
End;
|
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);
|
Procedure Win32PosToLCLPos(Sender: TObject; var Left, Top: SmallInt);
|
||||||
var
|
var
|
||||||
ORect: TRect;
|
ORect: TRect;
|
||||||
@ -922,6 +945,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
function GetFileVersion(FileName: string): dword;
|
||||||
var
|
var
|
||||||
buf: pointer;
|
buf: pointer;
|
||||||
|
@ -85,11 +85,6 @@ begin
|
|||||||
SetBounds(AWinControl, Params.Left, Params.Top, 0, 0);
|
SetBounds(AWinControl, Params.Left, Params.Top, 0, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
|
||||||
// TODO: needs to move
|
|
||||||
MCM_FIRST = $1000;
|
|
||||||
MCM_GETMINREQRECT = MCM_FIRST + 9;
|
|
||||||
|
|
||||||
procedure TWin32WSCustomCalendar.AdaptBounds(const AWinControl: TWinControl;
|
procedure TWin32WSCustomCalendar.AdaptBounds(const AWinControl: TWinControl;
|
||||||
var Left, Top, Width, Height: integer; var SuppressMove: boolean);
|
var Left, Top, Width, Height: integer; var SuppressMove: boolean);
|
||||||
var
|
var
|
||||||
|
@ -172,14 +172,6 @@ end;
|
|||||||
|
|
||||||
{ TWin32WSCustomForm }
|
{ 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;
|
function CalcBorderIconsFlags(const AForm: TCustomForm): dword;
|
||||||
var
|
var
|
||||||
BorderIcons: TBorderIcons;
|
BorderIcons: TBorderIcons;
|
||||||
|
Loading…
Reference in New Issue
Block a user