为什么托盘图标上下文菜单不适用于我的 RemoteApp?

发布于 2024-10-19 12:41:28 字数 577 浏览 12 评论 0原文

我有一个应用程序,它使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的往事 2024-10-26 12:41:28

发生这种情况的原因似乎是应用程序未收到 < RemoteApp 情况下的 code>WM_CONTEXTMENU 通知。通常的 WM_RBUTTONDOWNWM_RBUTTONUP 通知会到达,但仅此而已。奇怪的是,如果您尝试使用键盘激活上下文菜单,即使不涉及鼠标,您也会收到 WM_RBUTTONDOWNWM_RBUTTONUP 。按 Ctrl+Alt+End 似乎可以解决此问题;系统开始发送正常的 WM_CONTEXTMENU 通知。我的猜测是这是远程桌面客户端进程中的一个错误。

一种可能的解决方法是使用 WM_RBUTTONUP 触发上下文菜单,但这会破坏键盘可访问性,因此我不推荐它。

我确定的解决方法如下:

  1. 当您看到 WM_RBUTTONUP 通知时,设置一个较短的超时时间(50-100 毫秒)的计时器。
  2. 当您看到 WM_CONTEXTMENU 通知时,取消计时器并显示上下文菜单。
  3. 当计时器触发时,取消计时器并显示上下文菜单。

这应该适用于本地使用和 RemoteApp 使用。步骤 1 中的超时值需要足够长,以便在 WM_CONTEXTMENU 进入之前不会过期,但不再过期。

It appears that this happens because the application does not receive a WM_CONTEXTMENU notification in the RemoteApp case. The usual WM_RBUTTONDOWN and WM_RBUTTONUP notifications arrive, but that's all. Strangely, if you try to activate the context menu with the keyboard, you also receive WM_RBUTTONDOWN and WM_RBUTTONUP, even though the mouse wasn't involved. Pressing Ctrl+Alt+End appears to resolve this problem; the system starts sending normal WM_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:

  1. When you see a WM_RBUTTONUP notification, set a timer with a short timeout (50-100ms).
  2. When you see a WM_CONTEXTMENU notification, cancel the timer and display the context menu.
  3. When the timer fires, 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文