Why doesn't the tray icon context menu work for my RemoteApp?

只谈情不闲聊 提交于 2019-12-07 02:14:25

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.

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