SendMessage(hwnd, WM_CANCELMODE, 0, 0);
Note that when a menu is being displayed the program is in a modal loop, so
simply including this SendMessage just after TrackPopupMenuEx() won't do you
any good because the line won't be processed until after you have closed the
menu. You must find another means of sending the message to the program (you
can confirm that WM_CANCELMODE works by sending it when processing a
WM_TIMER message, but this presumably won't be the method of sending
WM_CANCELMODE that you will want to employ in your program).
I don't know what you are trying to accomplish, but you might find it useful
to look at "Creating an Internet Explorer-style Menu Bar on MSDN (in the
introductory section on the Common Controls).
--
Quixote
1. To reply to email address, remove donald.
2. Don't reply to email address (post here instead).
i would like to send WM_CANCELMODE when the user clicks anywhere on
the screen other than my popup menu. My application consists of a
system tray icon which causes a pop-up menu to appear when right click
on icon.
It sounds easy but I can't work it out. If somebody could help, it
would be much appreciated.
Thanks.
This is a problem specific to popup menus associated with the system tray
icon. You don't need to send WM_CANCELMODE, you just need to use
TrackPopupMenu in a suitably bizarre way. See MSDN article Q135788, "Menus
for Notification Icons Don't Work Correctly".
--
Quixote
1. To reply to email address, remove donald