任务栏图标上下文菜单为什么不能用于我的RemoteApp? [英] Why doesn't the tray icon context menu work for my RemoteApp?

查看:187
本文介绍了任务栏图标上下文菜单为什么不能用于我的RemoteApp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它使用 RemoteApp ,右键单击该图标不会显示上下文菜单.用于打开上下文菜单的各种基于键盘的方法也不起作用.

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?

编辑:另一则信息:如果我按Ctrl + Alt + End键以打开Windows安全性屏幕(可让您注销,锁定会话等),然后关闭该窗口屏幕上,上下文菜单开始工作.

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.

推荐答案

这似乎是由于应用程序未收到

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.

一种可能的解决方法是使用WM_RBUTTONUP触发上下文菜单,但这会破坏键盘的可访问性,因此我不建议这样做.

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. 当您看到WM_RBUTTONUP通知时,请将计时器设置为较短的超时时间(50-100毫秒).
  2. 当您看到WM_CONTEXTMENU通知时,取消计时器并显示上下文菜单.
  3. 当计时器启动时,取消计时器并显示上下文菜单.
  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.

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

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.

这篇关于任务栏图标上下文菜单为什么不能用于我的RemoteApp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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