Mirror

Taskbar hides windows/ size of taskbar (Views: 101)


Problem/Question/Abstract:

Taskbar hides windows/ size of taskbar

Answer:

Sometimes the taskbar covers a part of your application window and you would like to avoid that. The following procedure shows how to retrieve the size of the taskbar ('tray window'); the key information is the internal window's classname Shell_TrayWnd:


procedure TForm1.Button1Click(Sender: TObject);
var
  Tasklist: HWnd;
  Bordered: TRect;
begin
  Tasklist := FindWindow('Shell_TrayWnd', nil);
  GetWindowRect(Tasklist, Bordered);
  Label1.Caption := 'Left: ' + IntToStr(Bordered.Left);
  Label2.Caption := 'Right: ' + IntToStr(Bordered.Right);
  Label3.Caption := 'Top: ' + IntToStr(Bordered.Top);
  Label4.Caption := 'Bottom: ' + IntToStr(Bordered.Bottom);
end;


Note:
The taskbar window is always two pixels broader or higher than the screen, e.g. at a screen resolution of 800x600, the with would be 802 pixels.

<< Back to main page