我已经阅读了how to make a notification popup menu go away when clicking outside it,但是当我使用建议的代码时,右键单击会导致任务栏弹出菜单显示为我自己的。如何只显示我的菜单?这是我的代码:
SetForegroundWindow(Form1.Handle);
PopupMenu1.Popup(x, y);
PostMessage(Form1.Handle, WM_NULL, 0, 0);
编辑:好的,似乎我确实需要做一些与我在下面评论的内容相关的内容。
trayhandle := FindWindow('Shell_TrayWnd', '');
trayhandle := FindWindowEx(trayhandle, 0, 'TrayNotifyWnd', nil);
trayhandle := FindWindowEx(trayhandle, 0, 'SysPager', nil);
trayhandle := FindWindowEx(trayhandle, 0, 'ToolbarWindow32', nil);
PostMessage(trayHandle, WM_LBUTTONDOWN, MK_LBUTTON, 0);
PostMessage(trayHandle, WM_LBUTTONUP, MK_LBUTTON, 0);
SetForegroundWindow(Handle);
PopupMenu1.Popup(x, y);
PostMessage(Handle, WM_NULL, 0, 0);
我已完成其他工作并继续弹回这个应用程序,菜单(只有我的菜单)正确显示并且也正常消失。现在似乎工作正常(除了触发鼠标左键)?