當 Application.OnActivate 發生時,我目前在 SysTray 圖示附近彈出一個彈出視窗。但是我現在需要在 TaskBar 上單擊 App 按鈕的地方彈出它(在開始選單旁邊)。如何找出剛剛單擊的應用程式任務欄圖示的確切位置?
我知道我可以簡單地允許 App Form 出現并要求用戶單擊一個按鈕以顯示一個彈出視窗,但我需要更簡單/更快地為我的 App 使用 GUI。
if (mode = 2) or ( (x =0) and (y=0) ) then begin
ABData.cbSize := SizeOf(TAppBarData);
//ABData.hWnd := FindWindow('Shell_TrayWnd', nil);
SHAppBarMessage(ABM_GETTASKBARPOS, ABData);
with ABData.Rc do begin
if (Top > 0) then Edge := ABE_BOTTOM
else if (Bottom < Screen.Height) then Edge := ABE_TOP
else if Right < Screen.Width then Edge := ABE_LEFT
else Edge := ABE_RIGHT;
end;
X := 1; Y := 1;
if Edge = ABE_BOTTOM then begin
X := ABData.Rc.Right-20;
Y := ABData.Rc.Top;
end else if Edge = ABE_TOP then begin
X := ABData.Rc.Right;
Y := ABData.Rc.Top;
end else if Edge = ABE_LEFT then begin
X := ABData.Rc.Left;
Y := ABData.Rc.Bottom;
end else if Edge = ABE_RIGHT then begin
X := ABData.Rc.Right;
Y := ABData.Rc.Bottom;
end;
end;
uj5u.com熱心網友回復:
似乎最簡單的解決方案是檢查滑鼠位置并彈出滑鼠所在的位置:
pt := Mouse.CursorPos;
x := pt.x;
y:= pt.y;
PS:在 C# 和 C 中似乎還有另一種解決方案:
如何找到視窗的任務欄按鈕螢屏矩形?
uj5u.com熱心網友回復:
如果“任務欄圖示”是指您擁有的系統托盤圖示,那么您可以使用Shell_NotifyIconGetRect(). 但是,如果您指的是任務欄按鈕,則沒有(官方)方法可以確定其在任務欄上的位置。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/430535.html
