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

Remove the Windows Constraint on Minimum Form Size: Width and Height
How to make a Delphi form smaller then 112 / 118 pixels

By , About.com Guide

Small Delphi Form

By Windows design a form (window) has a size constraint that sets the minimum form height to the height of the caption bar and the width to 112 pixels (118 in XP theme).

This minimum size constraint is imposed by Windows to prevent a user from accidentially resizing a window so much that it becomes unusable.

There might be situations where you need to have your forms smaller then 112 pixels in width.

By handling the WM_GETMINMAXINFO Windows message, you can set your own size constraint that are applied when the user is resizing the form (or the size is set programmatically).

type
   TForm1 = class(TForm)
...
   private
     procedure GetMinMaxInfo(var Msg: TWMGETMINMAXINFO) ; message WM_GETMINMAXINFO;
...
implementation
Note also you have to "clear" the BorderIcons and the Caption properties of the form in order for this code to work.
Ah, I almost forgot: double check the Constraint property for the form and any of the controls on the form that use client alignement.
procedure TForm1.GetMinMaxInfo(var Msg: TWMGETMINMAXINFO) ;
begin
   with Msg.MinMaxInfo^ do
   begin
     ptMinTrackSize.X := 0; // min. Width
     ptMinTrackSize.Y := 0; // min. Height
   end;
end;

Delphi tips navigator:
» How to Capture the Screen Shot of the Active Window
« How to Browse Delphi's VCL Source Code

More Delphi Programming Quick Tips
Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. Delphi 2006 Tips
  7. Remove the Windows Constraint on Minimum Form Size: Width and Height (112 / 118)

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

All rights reserved.