2004. november 29., hétfő
How to position maximized forms
Problem/Question/Abstract:
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
{ Private declarations }
procedure WMGetMinMaxInfo(var msg: TWMGetMinmaxInfo); message WM_GETMINMAXINFO;
procedure TForm2.WMGetMinMaxInfo(var msg: TWMGetMinmaxInfo);
var
r: TRect;
begin
inherited;
SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
r.top := Application.Mainform.Height + Application.Mainform.Top;
with msg.MinMaxInfo^.ptMaxSize do
begin
x := r.right - r.left;
y := r.bottom - r.top;
end;
msg.Minmaxinfo^.ptmaxPosition := r.TopLeft;
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.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése