How to position maximized forms (Views: 6)


I am working on a project that must keep the 640x480 pixel screen size. I would like to make it MDI. I've designed a small form with a menu and a tool bar (like Delphi's IDE). The user will click on this IDE like form and a new window will be display. Here is the problem: When the user maximizes this window, it goes to (0,0) thus hiding IDE form.


Handle WM_GETMINMAXINFO, that allows you to specify position and size of the maximized window:

{ Private declarations }

procedure WMGetMinMaxInfo(var msg: TWMGetMinmaxInfo); message WM_GETMINMAXINFO;

procedure TForm2.WMGetMinMaxInfo(var msg: TWMGetMinmaxInfo);
  r: TRect;
  SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
  r.top := Application.Mainform.Height + Application.Mainform.Top;
  with msg.MinMaxInfo^.ptMaxSize do
    x := r.right - r.left;
    y := r.bottom - r.top;
  msg.Minmaxinfo^.ptmaxPosition := r.TopLeft;

This code will make the form use the full available screen area (minus taskbar) under the main form, you will need to modify it to limit it to a maximum of 640x480.

<< Back to main page