为什么托盘图标上下文菜单不适用于我的 RemoteApp?
我有一个应用程序,它使用 Shell_NotifyIcon
。该图标有一个包含各种重要命令的上下文菜单。当应用程序在本地系统上运行时,上下文菜单工作正常。但是,当应用程序作为终端服务运行时 RemoteApp,右键单击图标不显示上下文菜单。用于打开上下文菜单的各种基于键盘的方法也不起作用。
双击图标仍然按预期运行,所以我知道它并没有完全损坏。不过,我们也需要上下文菜单才能工作。有人知道可能出了什么问题吗?
编辑:还有一条信息:如果我按 Ctrl+Alt+End 打开 Windows 安全屏幕(可让您注销、锁定会话等),然后关闭该屏幕,上下文菜单开始工作。
I have an application which adds an icon to the notification area (aka the "system tray") using Shell_NotifyIcon
. The icon has a context menu with various important commands. When the app runs on the local system, the context menu works fine. However, when the app is run as a Terminal Services RemoteApp, right-clicking the icon does not display the context menu. The various keyboard-based methods for opening the context menu also don't work.
Double-clicking the icon still behaves as expected, so I know it's not totally broken. We need the context menu to work as well, though. Does anybody know what might be wrong?
Edit: One more piece of information: if I press Ctrl+Alt+End to open the Windows Security screen (which lets you log off, lock the session, etc), and then close that screen, the context menu starts working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发生这种情况的原因似乎是应用程序未收到 < RemoteApp 情况下的 code>WM_CONTEXTMENU 通知。通常的
WM_RBUTTONDOWN
和WM_RBUTTONUP
通知会到达,但仅此而已。奇怪的是,如果您尝试使用键盘激活上下文菜单,即使不涉及鼠标,您也会收到WM_RBUTTONDOWN
和WM_RBUTTONUP
。按 Ctrl+Alt+End 似乎可以解决此问题;系统开始发送正常的WM_CONTEXTMENU
通知。我的猜测是这是远程桌面客户端进程中的一个错误。一种可能的解决方法是使用
WM_RBUTTONUP
触发上下文菜单,但这会破坏键盘可访问性,因此我不推荐它。我确定的解决方法如下:
WM_RBUTTONUP
通知时,设置一个较短的超时时间(50-100 毫秒)的计时器。WM_CONTEXTMENU
通知时,取消计时器并显示上下文菜单。这应该适用于本地使用和 RemoteApp 使用。步骤 1 中的超时值需要足够长,以便在 WM_CONTEXTMENU 进入之前不会过期,但不再过期。
It appears that this happens because the application does not receive a
WM_CONTEXTMENU
notification in the RemoteApp case. The usualWM_RBUTTONDOWN
andWM_RBUTTONUP
notifications arrive, but that's all. Strangely, if you try to activate the context menu with the keyboard, you also receiveWM_RBUTTONDOWN
andWM_RBUTTONUP
, even though the mouse wasn't involved. Pressing Ctrl+Alt+End appears to resolve this problem; the system starts sending normalWM_CONTEXTMENU
notifications. My guess is that this is a bug in the remote desktop client process.One potential fix would be to trigger the context menu using
WM_RBUTTONUP
, but that breaks keyboard accessibility, so I don't recommend it.The workaround I settled on was the following:
WM_RBUTTONUP
notification, set a timer with a short timeout (50-100ms).WM_CONTEXTMENU
notification, cancel the timer and display the context menu.This should work for local usage and RemoteApp usage. The timeout value in step 1 needs to be long enough that it doesn't expire before the WM_CONTEXTMENU comes in, but no longer.