Enlarge a Form Over Screen Size

Submitted by:Andery Smith

Date added:21 May, 2014

Category:Delphi

Due to the default Windows handling of the WM_GETMINMAXINFO message, the max size of the form is set to the screen size. Add a button to a form and try this:

Tags: enlarge form , screen size

Code Snippet:

private
procedure WMGetMinMaxInfo
(var msg: TWMGetMinMaxInfo) ;
message WM_GETMINMAXINFO;
...

implementation
procedure TForm1.WMGetMinMaxInfo
(var msg: TWMGetMinMaxInfo) ;
begin
inherited;
with msg.MinMaxInfo^.ptMaxTrackSize do begin
X := GetDeviceCaps(Canvas.Handle, HORZRES)
+ (Width - ClientWidth) ;
Y := GetDeviceCaps(Canvas.Handle, VERTRES)
+ (Height - ClientHeight) ;
end;
end;

procedure TForm1.Button1Click(Sender: TObject) ;
Const
{$J+}
Rect: TRect = (Left:0; Top:0; Right:0; Bottom:0) ;
{$J-}
begin
if Left > 0 then begin
Rect := BoundsRect;
SetBounds(
Left - ClientOrigin.X,
Top - ClientOrigin.Y,
GetDeviceCaps(Canvas.Handle, HORZRES)
+ (Width - ClientWidth),
GetDeviceCaps(Canvas.Handle, VERTRES)
+ (Height - ClientHeight)
) ;
end
else BoundsRect := Rect;
end;
 
 

Comments