怎样才能取得任务栏的位置?(100分)

  • 主题发起人 主题发起人 阿拉宁波人
  • 开始时间 开始时间

阿拉宁波人

Unregistered / Unconfirmed
GUEST, unregistred user!
1. 怎样才能取得任务栏的位置,比如是上、下、左、右?<br>2. 怎样才能取得任务栏的位置变动消息?<br>
 
1:我用ShAppBarMessage,不过得到的位置总是在下方?不知道那个地方不对?还有,用Shappbarmessage不能设置<br>任务条的AutoHide。
 
uses<br>&nbsp; shellapi;<br><br>var<br>&nbsp; abd: TAppBarData;<br>begin<br>&nbsp; abd.cbSize := sizeof(abd);<br>&nbsp; SHAppBarMessage(ABM_GETTASKBARPOS, abd);<br>&nbsp; abd.rc.Left<br>&nbsp; abd.rc.Top<br>&nbsp; abd.rc.Bottom<br>&nbsp; abd.rc.Right<br>
 
第一个问题已解决,请教第二个问题。
 
没人知道了吗?
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; ApplicationEvents1: TApplicationEvents;<br>&nbsp; &nbsp; procedure ApplicationEvents1SettingChange(Sender: TObject;<br>&nbsp; &nbsp; &nbsp; Flag: Integer; const Section: String; var Result: Integer);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.ApplicationEvents1SettingChange(Sender: TObject;<br>&nbsp; Flag: Integer; const Section: String; var Result: Integer);<br>begin<br>//在这二<br>end;<br>
 
yanlei:<br>&nbsp; 所说的可以实现,但是经过我查看源码,发现是WM_SettingChange消息,我觉得触发这个<br>消息的不仅仅是改变状态栏位置的情况,我的设想是最好能通过状态栏本身的消息得到。
 
var H: HWND;<br>&nbsp; &nbsp; R: TRECT;<br>GetWindowRect(H,R);
 
这个简单,一下程序在delphi6 win2000 server下通过<br>procedure TForm1.Button1Click(Sender: TObject);<br>var abd : TAPPBARDATA;<br>&nbsp; &nbsp; hwndTaskBar : HWND;<br>&nbsp; &nbsp; nState : UINT;<br>begin<br>&nbsp; abd.cbSize := sizeof(abd);<br>&nbsp; hwndTaskBar := FindWindow('Shell_TrayWnd',NIL);<br>&nbsp; abd.hWnd := hwndTaskBar;<br>&nbsp; nState := SHAppBarMessage(ABM_GETSTATE,abd);<br>&nbsp; SHAppBarMessage(ABM_GETTASKBARPOS,abd);<br>&nbsp; if((nState and ABS_ALWAYSONTOP)&lt;&gt;0) then<br>&nbsp; &nbsp; Label1.Caption := 'always on top';<br>&nbsp; if((nState and ABS_AUTOHIDE)&lt;&gt;0) then<br>&nbsp; &nbsp; Label1.Caption := 'auto hide';<br>&nbsp; case abd.uEdge of<br>&nbsp; &nbsp; ABE_TOP : Label1.Caption := Label1.Caption + ' &nbsp;top-edge';<br>&nbsp; &nbsp; ABE_BOTTOM : Label1.Caption := Label1.Caption + ' &nbsp;bottom-edge';<br>&nbsp; &nbsp; ABE_LEFT : Label1.Caption := Label1.Caption + ' &nbsp;left-edge';<br>&nbsp; &nbsp; ABE_RIGHT : Label1.Caption := Label1.Caption + ' &nbsp;right-edge';<br>&nbsp; end;<br>end;
 
补充一句,要在uses中加上ShellApi这一项,不然编译通不过
 
多人接受答案了。
 
后退
顶部