having handle to a menu (HMENU) is it possible to find it's parent window (HWND)?

耗尽温柔 提交于 2019-12-23 02:17:57

问题


I know about the option for system menu, that is the alt+space one. And it's not pretty it involves looping all open windows through GetNextWindow. But I want to ask in more general way. That is having any menu handle, not necessarily to system menu (that is easy to find for any window) is it possible to get to its parent window ?


回答1:


In the particular case when hmenu obtained on the fly from an existing menu-window (class #32768): you can use GUITHREADINFO.hwndMenuOwner via GetGUIThreadInfo(GetWindowThreadProcessId). "On the fly" means: via SendMessageTimeout(MN_GETHMENU) or via GetMenuBarInfo(OBJID_CLIENT), after WindowFromPoint.




回答2:


No. Menus can be shared across windows, so there's no unique mapping from menus to windows.



来源:https://stackoverflow.com/questions/20665457/having-handle-to-a-menu-hmenu-is-it-possible-to-find-its-parent-window-hwnd

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