【問題】Shell_TrayWnd 的位置?
發表於 : 2008年 11月 27日, 18:20
寫個小範例來解決這個問題. 利用 findwindow 先找出 Shell_TrayWnd 的 handle 後, 再利用 SHAppBarMessage 來取得 AppBar 的資料即可!!
記得要使用 ShellAPI 哦~
參考資料:
http://bdn.borland.com/article/0,1410,26977,00.html
記得要使用 ShellAPI 哦~
參考資料:
http://bdn.borland.com/article/0,1410,26977,00.html
代碼: 選擇全部
procedure Tform1.Button3Click(Sender: TObject);
var
sthandle: HWND;
abd: TAppBarData;
begin
sthandle := FindWindow('Shell_TrayWnd', nil);
if sthandle <> 0 then
begin
abd.cbSize := SizeOf(abd);
if SHAppBarMessage(ABM_GETTASKBARPOS, abd) = 0 then
raise Exception.Create('SHAppBarMessage returned false when trying to find the Task Bar''s position');
// 0 for left, 1 for top, 2 for right, 3 for bottom
case abd.uEdge of
0: ShowMessage('AppBar is on left side');
1: ShowMessage('AppBar is on top side');
2: ShowMessage('AppBar is on right side');
3: ShowMessage('AppBar is on bottom side');
else
ShowMessage('AppBar is unknown position!');
end;
end;
end;