当SysTray出现时,我在Application.OnActivate图标附近弹出一个弹出。不过,我现在需要弹出它,在TaskBar上单击App按钮(在“开始”菜单旁边)。如何找到我的应用程序任务栏图标的确切位置?
我知道我可以简单地允许appear出现,并要求用户单击一个使弹出窗口出现的按钮,但我需要更简单、更快地为我的应用程序使用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;
发布于 2022-02-18 00:37:52
似乎最简单的解决方案是检查鼠标的位置和弹出鼠标所在的位置:
pt := Mouse.CursorPos;
x := pt.x;
y:= pt.y;
PS:在C#和C++中似乎也有另一种解决方案:
发布于 2022-02-17 13:55:15
如果您所说的“任务栏图标”指的是您拥有的系统托盘图标,那么您可以使用Shell_NotifyIconGetRect()
。但是,如果您指的是一个任务栏按钮,那么就没有(正式的)方法来确定它在任务栏上的位置。
https://stackoverflow.com/questions/71153093
复制