When a tray icon is clicked, the specified callback message is sent to the specified window. But, how can I find out where to display a shortcut menu? Ie, how can I correctly position a context menu next to the system tray?
Printable View
When a tray icon is clicked, the specified callback message is sent to the specified window. But, how can I find out where to display a shortcut menu? Ie, how can I correctly position a context menu next to the system tray?
I'm using this:
POINT p;
GetCursorPos(&p);
Cool thanks.
Another problem: When I display the menu, but I click somewhere else on the screen, the menu stays there, and I can't do anything, effectively the computer is useless, until I either go back to the program or click the menu. How can I remove this behavior?
After the call to GetCursorPos() call SetForegroundWindow() with your main window handle, then call TrackPopupMenuEx().
Works like a charm, thanks.
you schould bring your program's window to front, when showing the menu (even if it's not shown):
SetForegroundWindow(hWnd);
edit: too slow ^^
And one more: How can I make the bottom right corner of the menu where the cursor is? Every other context menu is like that, but mine has the cursor at the top left.
http://msdn.microsoft.com/library/de...opupmenuex.asp
its one of the flags