如何确定窗口是否具有文件菜单? [英] How to determine if the window has a file menu?
问题描述
我是MFC的初学者,遇到了一个问题.
当我得到一个窗口的HWND时,如何确定该窗口是否具有文件菜单(例如File..Edit ...等).有时我们遇到带有标题栏的窗口,然后我们遇到带有标题栏和菜单栏的窗口……有时根本没有,所以我怎么能检测到这是代码.有什么办法吗?
我已经尝试使用GetWindowInfo(m_pSelectedParentWindow,&pwindowInfo);
其中m_pSelectedParentWindow是窗口的HWND,而pWindowInfo是WINDOWINFO变量.我还没有真正找到任何共同的趋势.
有任何想法吗?
I am a beginner at MFC, have come across an issue.
When I get the HWND of a window, how can I determine whether the window has a File Menu (for instance File..Edit...etc..). Sometimes we come across windows, with just a title bar, then we come across windows with a title bar and a menu bar...sometimes neither of them at all, so how can I detect this is code. Is there any way?
I have tried using GetWindowInfo(m_pSelectedParentWindow,&pwindowInfo);
Where m_pSelectedParentWindow is the HWND of the window and pWindowInfo is a WINDOWINFO variable. I haven''t really been able to find any common trends.
Any ideas?
推荐答案
是否 ^ ]或此 [ ^ ]帮助吗?
Does this[^] or this[^] help?
使用MFC,您通常具有CWnd
派生类.如果只有句柄,则可以使用CWnd::FromHandle()
来获取临时的CWnd
对象.
然后使用 GetMenu() [
With MFC, you usally haveCWnd
derived classes. If you only have the handle, you can useCWnd::FromHandle()
to get a temporaryCWnd
object.
Then use the GetMenu() [^] function to access the menu and iterate through it and it''s sub-menus. But you should check that the window is not a child window before usingGetMenu()
.
这篇关于如何确定窗口是否具有文件菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!