mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 03:59:10 +02:00
win32: move wm_getminmaxinfo to the form window proc
git-svn-id: trunk@25293 -
This commit is contained in:
parent
3e6c6b0ea4
commit
77895ca1a7
@ -832,32 +832,6 @@ var
|
|||||||
Result := WindowInfo^.isComboEdit and (ComboBoxHandleSizeWindow = Windows.GetParent(Window));
|
Result := WindowInfo^.isComboEdit and (ComboBoxHandleSizeWindow = Windows.GetParent(Window));
|
||||||
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.ptMaxTrackSize);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure HandleBitBtnCustomDraw(ABitBtn: TCustomBitBtn);
|
procedure HandleBitBtnCustomDraw(ABitBtn: TCustomBitBtn);
|
||||||
var
|
var
|
||||||
DrawInfo: PNMCustomDraw absolute NMHdr;
|
DrawInfo: PNMCustomDraw absolute NMHdr;
|
||||||
@ -1534,8 +1508,6 @@ begin
|
|||||||
LMessage.Result := DLGC_WANTALLKEYS;
|
LMessage.Result := DLGC_WANTALLKEYS;
|
||||||
WinProcess := false;
|
WinProcess := false;
|
||||||
end;
|
end;
|
||||||
WM_GETMINMAXINFO:
|
|
||||||
SetMinMaxInfo(PMINMAXINFO(LParam)^);
|
|
||||||
WM_HELP:
|
WM_HELP:
|
||||||
if Window = Win32WidgetSet.AppHandle then
|
if Window = Win32WidgetSet.AppHandle then
|
||||||
Application.HelpCommand(0, LParam);
|
Application.HelpCommand(0, LParam);
|
||||||
|
@ -98,7 +98,6 @@ 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);
|
||||||
|
|
||||||
@ -966,26 +965,6 @@ 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;
|
||||||
|
@ -292,6 +292,68 @@ begin
|
|||||||
BorderStyle), false, BorderStyleToWin32FlagsEx(BorderStyle));
|
BorderStyle), false, BorderStyleToWin32FlagsEx(BorderStyle));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function CustomFormWndProc(Window: HWnd; Msg: UInt; WParam: Windows.WParam; LParam: Windows.LParam): LResult; stdcall;
|
||||||
|
|
||||||
|
procedure LCLFormSizeToWin32Size(Form: TCustomForm; var AWidth, AHeight: Integer);
|
||||||
|
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 SetMinMaxInfo(WinControl: TWinControl; 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(WinControl), IntfWidth, IntfHeight);
|
||||||
|
|
||||||
|
if AWidth>0 then
|
||||||
|
pt.X:= IntfWidth;
|
||||||
|
if AHeight>0 then
|
||||||
|
pt.Y := IntfHeight;
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
with WinControl.Constraints do
|
||||||
|
begin
|
||||||
|
SetWin32SizePoint(MinWidth, MinHeight, MinMaxInfo.ptMinTrackSize);
|
||||||
|
SetWin32SizePoint(MaxWidth, MaxHeight, MinMaxInfo.ptMaxTrackSize);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
Info: PWin32WindowInfo;
|
||||||
|
WinControl: TWinControl;
|
||||||
|
begin
|
||||||
|
Info := GetWin32WindowInfo(Window);
|
||||||
|
WinControl := Info^.WinControl;
|
||||||
|
case Msg of
|
||||||
|
WM_GETMINMAXINFO:
|
||||||
|
begin
|
||||||
|
SetMinMaxInfo(WinControl, PMINMAXINFO(LParam)^);
|
||||||
|
Exit(CallDefaultWindowProc(Window, Msg, WParam, LParam));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
Result := WindowProc(Window, Msg, WParam, LParam);
|
||||||
|
end;
|
||||||
|
|
||||||
class function TWin32WSCustomForm.CreateHandle(const AWinControl: TWinControl;
|
class function TWin32WSCustomForm.CreateHandle(const AWinControl: TWinControl;
|
||||||
const AParams: TCreateParams): HWND;
|
const AParams: TCreateParams): HWND;
|
||||||
var
|
var
|
||||||
@ -328,7 +390,7 @@ begin
|
|||||||
Width := Bounds.Right - Bounds.Left;
|
Width := Bounds.Right - Bounds.Left;
|
||||||
Height := Bounds.Bottom - Bounds.Top;
|
Height := Bounds.Bottom - Bounds.Top;
|
||||||
end;
|
end;
|
||||||
SubClassWndProc := nil;
|
SubClassWndProc := @CustomFormWndProc;
|
||||||
if ((Application = nil) or (Application.MainForm <> lForm)) and
|
if ((Application = nil) or (Application.MainForm <> lForm)) and
|
||||||
( not (csDesigning in lForm.ComponentState) and
|
( not (csDesigning in lForm.ComponentState) and
|
||||||
(lForm.ShowInTaskBar = stAlways)) then
|
(lForm.ShowInTaskBar = stAlways)) then
|
||||||
@ -565,7 +627,7 @@ begin
|
|||||||
Top := LongInt(CW_USEDEFAULT);
|
Top := LongInt(CW_USEDEFAULT);
|
||||||
Width := LongInt(CW_USEDEFAULT);
|
Width := LongInt(CW_USEDEFAULT);
|
||||||
Height := LongInt(CW_USEDEFAULT);
|
Height := LongInt(CW_USEDEFAULT);
|
||||||
SubClassWndProc := nil;
|
SubClassWndProc := @CustomFormWndProc;
|
||||||
end;
|
end;
|
||||||
// create window
|
// create window
|
||||||
FinishCreateWindow(AWinControl, Params, false);
|
FinishCreateWindow(AWinControl, Params, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user