I have a form without caption, using on double click to maximize : Code looks like this:
procedure xxxxxx;
begin
if Form1.WindowState=wsNormal then
begin
Form1.WindowState:=wsMaximized;
Form1.SetBounds(0,0,screen.Width,screen.Height-getHeightOfTaskBar);
end
else
begin
Form1.WindowState:=wsNormal;
end;
ShowTrayWindow;
end;
function getHeightOfTaskBar : integer;
var hTaskBar:HWND;
rect : TRect;
begin
hTaskbar := FindWindow('Shell_TrayWnd', Nil );
if hTaskBar<>0 then
GetWindowRect(hTaskBar, rect);
Result:=rect.bottom - rect.top;
end;
This works good, except that I have to figure out where is task bar to reset SetBounds ...
What is the correct way to do this?
Thanks.
Sounds okay but like Drejc pointed out, the taskbar can appear anywhere, so too could additional docked sidebars like Google Desktop, Winamp, etc.
Instead perhaps use something like Screen.WorkAreaRect to get the client area of the screen. E.g.
with Screen.WorkAreaRect do
Form1.SetBounds(Left, Top, Right - Left, Bottom - Top);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With