Author: Jonas Bilinkevicius
How to determine the size of the Windows taskbar
Answer:
Solve 1:
You need to get the Rect in the rc member of the APPBARData structure and subtract
the top from the bottom.
1 procedure TForm1.Button1Click(Sender: TObject);
2 var3 appbardata: TAppBarData;
4 Rect: TRect;
5 taskBarHeight: Integer;
6 begin7 AppBarData.cbSize := 0;
8 AppBarData.hWnd := 0;
9 AppBarData.rc.Left := 0;
10 AppBarData.rc.Top := 0;
11 AppBarData.rc.Bottom := 0;
12 AppBarData.rc.Right := 0;
13 SHAppBarMessage(ABM_GETTASKBARPOS, appbardata);
14 Rect := appbardata.rc;
15 taskBarHeight := Rect.Bottom - Rect.Top;
16 ShowMessage(IntToStr(taskBarHeight));
17 end;
Solve 2:
18 function GetTaskBarSize: TRect;
19 var20 wnd: HWND;
21 begin22 wnd := FindWindow('Shell_TrayWnd', nil);
23 if wnd > 0 then24 GetWindowRect(wnd, Result)
25 else26 Result := Rect(0, 0, 0, 0);
27 end;
Solve 3:
This is one way to get the height of the taskbar:
28 function GetTaskBarRect: TRect;
29 var30 TBData: TAppBarData;
31 begin32 TBData.cbSize := sizeof(TAppBarData);
33 SHAppBarMessage(ABM_GETTASKBARPOS, TBData);
34 Result := TBData.rc;
35 end;