Mirror

Set minimum/maximum values for a resizable form (Views: 706)


Problem/Question/Abstract:

Set minimum/maximum values for a resizable form

Answer:

There is a windows message that requests the minimum and the maximum value for a
resizable window ('form').
The following code makes sure that a window of type TForm1 is not smaller than
100x100 and not larger than 200x200 pixels:

type
  TForm1 = class(TForm)
  protected
    procedure WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
      message WM_GETMINMAXINFO;
  end;

procedure TForm1.WMGetMinMaxInfo(var Message: TWMGetMinMaxInfo);
begin
  with Message.MinMaxInfo^ do
  begin
    ptMinTrackSize := Point(100, 100);
    ptMaxTrackSize := Point(200, 200);
  end;
end;

<< Back to main page