Click here to Skip to main content
16,015,755 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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?
Posted

With MFC, you usally have CWnd derived classes. If you only have the handle, you can use CWnd::FromHandle() to get a temporary CWnd 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 using GetMenu().
 
Share this answer
 
Comments
weirdProgrammer-2 21-Jun-12 8:56am    
Thanks a lot, very comprehensive!
Does this[^] or this[^] help?
 
Share this answer
 
Comments
weirdProgrammer-2 21-Jun-12 8:45am    
Thank you so much! Such a nice simple solution. I just wasted two hours of my life trying a figure it out. Thanks again!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900