-->

MS Windows- Main window no response when show menu

2019-09-08 06:49发布

问题:

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



标签: icons tray