Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming

Enlarge a Form Over Screen Size

By Zarko Gajic, About.com

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:

~~~~~~~~~~~~~~~~~~~~~~~~~
...
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;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» Left, Mid, Right String
« Capture Maximize/Minimize Menu button click

Zarko Gajic
Guide since 1998

Zarko Gajic
Delphi Programming Guide

Explore Delphi Programming

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Delphi Programming

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 1999 Delphi Tips
  7. Enlarge a Form Over Screen Size

©2009 About.com, a part of The New York Times Company.

All rights reserved.