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 wasn't available until Windows 7.
WM_CONTEXTMENU is available starting in Win2k, but only provides coordinates in wParam as of Vista (and when specifying NOTIFYICON_VERSION_4).
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;
// ...
}
// ...