Author: William Gerbert
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:
1 procedure TForm1.Button1Click(Sender: TObject);
2 var3 Tasklist: HWnd;
4 Bordered: TRect;
5 begin6 Tasklist := FindWindow('Shell_TrayWnd', nil);
7 GetWindowRect(Tasklist, Bordered);
8 Label1.Caption := 'Left: ' + IntToStr(Bordered.Left);
9 Label2.Caption := 'Right: ' + IntToStr(Bordered.Right);
10 Label3.Caption := 'Top: ' + IntToStr(Bordered.Top);
11 Label4.Caption := 'Bottom: ' + IntToStr(Bordered.Bottom);
12 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.