如何在Windows XP上放置通知(托盘)图标上下文菜单? [英] How do I position a notification (tray) icon context menu on Windows XP?
本文介绍了如何在Windows XP上放置通知(托盘)图标上下文菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用C ++和Win32.
I'm using C++ and Win32.
我希望上下文菜单和设置对话框显示在任务栏图标附近.我想我需要图标的坐标才能做到这一点.
I want my context menu and settings dialog to show up near the tray icon. I think I need the icon's coordinates to do that.
Shell_NotifyIconGetRect在Windows 7之前不可用.
Shell_NotifyIconGetRect wasn't available until Windows 7.
WM_CONTEXTMENU从Win2k开始可用,但是仅在Vista或更高版本(以及指定NOTIFYICON_VERSION_4时)中的wParam中提供坐标.
WM_CONTEXTMENU is available starting in Win2k, but only provides coordinates in wParam as of Vista (and when specifying NOTIFYICON_VERSION_4).
推荐答案
使用GetCursorPos检索点击坐标的效果很好:
Retrieving the click coordinates with GetCursorPos works well:
// Inside WndProc's switch(message)...
case WM_APP_NOTIFYCALLBACK:
switch (LOWORD(lParam))
{
case WM_CONTEXTMENU: // XP and later
{
POINT pt = {};
if( GetCursorPos(&pt) )
ShowContextMenu(hWnd, pt, iStatus);
}
break;
// ...
}
// ...
这篇关于如何在Windows XP上放置通知(托盘)图标上下文菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文