MS Windows- Main window no response when show menu on a tray notify icon(use a hidden window to process message)

こ雲淡風輕ζ 提交于 2019-12-25 10:54:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!