Difference between revisions of "Application disable resize over Dock"
From Lazarus wiki
Jump to navigationJump to searchLine 20: | Line 20: | ||
begin | begin | ||
Self.OnConstrainedResize:= @FormConstrainedResize; //not published in LCL<1.7 | Self.OnConstrainedResize:= @FormConstrainedResize; //not published in LCL<1.7 | ||
+ | end; | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | 2) Write code in handler to change MaxHeight. | ||
+ | Value must be "max workarea height" minus current form's Top. | ||
+ | |||
+ | <syntaxhighlight> | ||
+ | procedure TfmMain.FormConstrainedResize(Sender: TObject; var MinWidth, MinHeight, | ||
+ | MaxWidth, MaxHeight: TConstraintSize); | ||
+ | var | ||
+ | RWork: TRect; | ||
+ | begin | ||
+ | {$ifndef darwin} exit; {$endif} | ||
+ | RWork:= Screen.Monitors[0].WorkareaRect; | ||
+ | MaxHeight:= RWork.Bottom - RWork.Top - Top; | ||
end; | end; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 16:52, 24 March 2017
On macOS it's often needed to disable app window's resize below OS Dock. But Lazarus forms always resize below it. How to disable this resize?
1) Create TForm.OnConstrainedResize handler for your form. Note, it was not "published" in LCL until LCL 1.7. Create it by hands:
TForm1 = class(TForm)
...
private
...
procedure FormConstrainedResize(Sender: TObject; var MinWidth, MinHeight,
MaxWidth, MaxHeight: TConstraintSize);
...
procedure TfmMain.FormCreate(Sender: TObject);
begin
Self.OnConstrainedResize:= @FormConstrainedResize; //not published in LCL<1.7
end;
2) Write code in handler to change MaxHeight. Value must be "max workarea height" minus current form's Top.
procedure TfmMain.FormConstrainedResize(Sender: TObject; var MinWidth, MinHeight,
MaxWidth, MaxHeight: TConstraintSize);
var
RWork: TRect;
begin
{$ifndef darwin} exit; {$endif}
RWork:= Screen.Monitors[0].WorkareaRect;
MaxHeight:= RWork.Bottom - RWork.Top - Top;
end;