Author: Tomas Rutkauskas
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.
Answer:
Handle WM_GETMINMAXINFO, that allows you to specify position and size of the
maximized window:
private
1 { Private declarations }2 3 procedure WMGetMinMaxInfo(var msg: TWMGetMinmaxInfo); message WM_GETMINMAXINFO;
4 5 procedure TForm2.WMGetMinMaxInfo(var msg: TWMGetMinmaxInfo);
6 var7 r: TRect;
8 begin9 inherited;
10 SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
11 r.top := Application.Mainform.Height + Application.Mainform.Top;
12 with msg.MinMaxInfo^.ptMaxSize do13 begin14 x := r.right - r.left;
15 y := r.bottom - r.top;
16 end;
17 msg.Minmaxinfo^.ptmaxPosition := r.TopLeft;
18 end;
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.