Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
Member Area
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Become a Member
-Why sign up!
-Chat Online!
-Indexes NEW!!
-Build your resume
-Find a job
-Post a job
-Resume Search
-Link to us
Visit Embarcadero
Embarcadero Community
How to get detailed information about the Windows taskbar programmatically Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Delphi 2.x
User Rating
No Votes
# Votes
DSP, Administrator
Reference URL:
			Author: Jonas Bilinkevicius
\I'm trying to determine the edge and rectangle of the Windows taskbar, using the 
SHAppBarMessage API - but how do I get the Windows taskbar handle?


I put a procedure together that gets all the information one would want to get 
about the TaskBar: Pos (Rect), Edge, window handle, and whether it's set to be 
AutoHide or AlwaysOnTop. I got the parameter and return information by following 
the parameter value entries within the Win32 Programmers' reference Online Help 
file. I also used a 1 second timer to fire the ButtonClick, so that I could test 
dragging and resizing the TaskBar. I'm not sure if the "Edge section" of code 
(ABM_GETAUTOHIDEBAR) will work properly if there are other AppBars on the system.
2   procedure GetTaskBarData(var AppBarInfo: TAppBarData; var AutoHide, AlwaysOnTop:
3     boolean);
4   var
5     i, RetVal: Cardinal;
6   begin
7     fillchar(AppBarInfo, sizeof(AppBarInfo), 0);
8     AppBarInfo.cbSize := sizeof(AppBarInfo);
9     RetVal := ShAppBarMessage(ABM_GETSTATE, AppBarInfo);
10    AutoHide := RetVal and ABS_AUTOHIDE > 0;
11    AlwaysOnTop := RetVal and ABS_ALWAYSONTOP > 0;
12    for i := 0 to 3 do
13    begin {ask all the edges}
14      AppBarInfo.uEdge := i; {then drop the Taskbar Handle into AppBarInfo}
15      AppBarInfo.hWnd := ShAppBarMessage(ABM_GETAUTOHIDEBAR, AppBarInfo);
16      if AppBarInfo.hWnd <> 0 then
17        break;
18      {the Taskbar's edge value is left in uEdge by the break}
19    end;
20    SHAppBarMessage(ABM_GETTASKBARPOS, AppBarInfo);
21  end;
23  procedure TForm1.Button1Click(Sender: TObject);
24  var
25    ABI: TAppBarData;
26    AHide, AlOnTop: Boolean;
27    s: string;
28  begin
29    GetTaskBarData(ABI, AHide, AlOnTop);
30    with ABI do
31    begin
32      caption := format('%d %d %d %d', [rc.left,, rc.right, rc.bottom]);
33      case uEdge of
34        ABE_BOTTOM: s := 'Bottom';
35        ABE_LEFT: s := 'Left';
36        ABE_RIGHT: s := 'Right';
37        ABE_TOP: S := 'Top';
38      end;
39      if AHide then
40        s := s + ' AutoHide';
41      if AlOnTop then
42        s := s + ' AlwaysOnTop';
43      caption := caption + ' ' + s;
44    end;
45  end;

Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10


Share this page
Download from Google

Copyright © Mendozi Enterprises LLC