MS Windows-主窗口在托盘上显示菜单时无响应通知图标(使用隐藏窗口处理消息) [英] MS Windows- Main window no response when show menu on a tray notify icon(use a hidden window to process message)

查看:125
本文介绍了MS Windows-主窗口在托盘上显示菜单时无响应通知图标(使用隐藏窗口处理消息)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现了一个类,这个类将显示一个托盘图标。要处理来自图标的消息,我必须创建一个隐藏窗口。

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)//添加
TrackPopupMenu()

SetForegroundWindow(message-only-hiden-window) // added TrackPopupMenu()

解决方案:要纠正第一个行为,您需要在调用TrackPopupMenu或TrackPopupMenuEx之前将当前窗口设置为前景窗口。

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.

问题是现在,在调用SetForegroundWindow(message-only-hiden-window)后,主应用程序窗口将无响应(无法调整大小)我可以看到主窗口实际上是在spy ++中获取这些消息。
如果没有调用SetForegroundWindow(message-only-hiden-window),请记住这个想法。精细。菜单不会消失。

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.

推荐答案

已解决。我忘了在仅消息窗口中返回DefWindowProc。棘手的

resolved. I have forgot return DefWindowProc in the message only window. tricky

这篇关于MS Windows-主窗口在托盘上显示菜单时无响应通知图标(使用隐藏窗口处理消息)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆