2009. szeptember 13., vasárnap
How to correctly maximize a window
Problem/Question/Abstract:
I have some forms with the property WindowState set to wsMaximized. The problem is that some forms are hiding the taskbar. I can't find the problem since some others forms are working fine.
Answer:
Solve 1:
If I'm right, the only way to get correctly maximized windows (regarding the taskbar and other "taskbar like" windows) is using API functions:
var
x: pointer;
r: TRect;
begin
x := Addr(r);
SystemParametersInfo(SPI_GETWORKAREA, 0, x, 0);
Left := 0;
Width := r.Right;
Top := 0;
Height := r.Bottom;
{ ... }
Solve 2:
This seems to be a particular problem when you do it in the forms OnCreate event. To fix it add a handler for the WM_GETMINMAXINFO message:
private
{ Private declarations }
procedure wmGetMinMaxInfo(var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
procedure TForm1.wmGetMinMaxInfo(var msg: TWMGetMinMaxInfo);
var
r: TRect;
begin
SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
with msg.MinMaxInfo^ do
begin
ptMaxSize := r.BottomRight;
ptMaxPosition := r.TopLeft;
end;
end;
If your form is set to Position := poDesigned and WindowState := wsMaximized, then don't set any value for Constraints. Otherwise the form won't maximize correctly at runtime, if the Windows taskbar is resized.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése