Author: Tomas Rutkauskas
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:
1 var2 x: pointer;
3 r: TRect;
4 begin5 x := Addr(r);
6 SystemParametersInfo(SPI_GETWORKAREA, 0, x, 0);
7 Left := 0;
8 Width := r.Right;
9 Top := 0;
10 Height := r.Bottom;
11 { ... }
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
12 { Private declarations }13 14 procedure wmGetMinMaxInfo(var msg: TWMGetMinMaxInfo); message WM_GETMINMAXINFO;
15 16 procedure TForm1.wmGetMinMaxInfo(var msg: TWMGetMinMaxInfo);
17 var18 r: TRect;
19 begin20 SystemParametersInfo(SPI_GETWORKAREA, 0, @r, 0);
21 with msg.MinMaxInfo^ do22 begin23 ptMaxSize := r.BottomRight;
24 ptMaxPosition := r.TopLeft;
25 end;
26 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.