-
Sys Tray..
Code:
case WM_SHELLNOTIFY:
{
if(lParam == WM_RBUTTONDOWN) //right-click the icon
{
POINT pt;
GetCursorPos(&pt);
TrackPopupMenu(hPopupMenu1,TPM_RIGHTALIGN,pt.x,pt.y,NULL,
hwnd,NULL);
}
//left-click or double-click the icon
else if((lParam == WM_LBUTTONDOWN) || (lParam == WM_LBUTTONDBLCLK))
{
POINT pt;
GetCursorPos(&pt);
TrackPopupMenu(hPopupMenu2, TPM_RIGHTALIGN, pt.x, pt.y, NULL,
hwnd, NULL);
}
}
break;
This is what puts my window in the system tray. Everything works perfectly fine. The only thing is that when the menu is poped from the icon, if you click, for example,the desktop while it is visible and poped, it does not disappear. It just sits there, and disappears when i move back over it. How would I make it go away as soon as I click somewhere else? Thanks!
Amon Ra
-
Before you use TrackPopupMenu, use SetForegroundWindow on the window you associated with the icon. Bizarre, but it works.
-
Would that be the main window(hwnd)?
-
Whichever window you supplied to the NOTIFYICONDATA struct.
-