问题
I implemented an class, this class will show an tray icon. to handle the message from the icon, I have to create a hidden window.
Eevery thing works fine, except if You click outside of the icon, icon will not disappear. I have fixed this by adding code below:
SetForegroundWindow(message-only-hiden-window) // added TrackPopupMenu()
RESOLUTION:To correct the first behavior, you need to make the current window the foreground window before calling TrackPopupMenu or TrackPopupMenuEx.
Now I get the expect result: the menu can disappear if you click outside of the tray icon.
The problem is now, after the call of SetForegroundWindow(message-only-hiden-window) the main app window will no responding(cannot resize move) I can see the main window actually get those messages in spy++. Keep this the mind if no call on SetForegroundWindow(message-only-hiden-window). Fine. Except the menu will not disappear.
Anyone has experience on similar situation? How do you implement an tray icon which has no foreground window at all?
Any kind of help will be appreciated. If you wanna the source code I can email you.
回答1:
resolved. I have forgot return DefWindowProc in the message only window. tricky
来源:https://stackoverflow.com/questions/7214368/ms-windows-main-window-no-response-when-show-menu-on-a-tray-notify-iconuse-a-h