Solved

How to get HWND from a CMenu

Posted on 2004-08-19
10
1,090 Views
Last Modified: 2013-11-20
Hi all,
i wonder on how to get the HWND for a CMenu, sind it's not derived from CWnd.
The reson is that i want to change the window style of a popup menu.
Therefore i wrote my own menu class derived it from CMenu and implemented MeasureItem and DrawItem to have a ownerdrawn menu.
But I want to have the popup menu shown up as a flat window without any border.
Thats why i want to get the hwnd or if possible the CWnd* of this menu.

Any suggestions?
0
Comment
Question by:ulf_k
  • 5
  • 4
10 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 60 total points
Comment Utility
I don't think a CMenu has a HWND (or CWnd*).  As you said it is not derived from CWnd.  It may use the window that owns it.
Style - in resource editor create a main menu as you normally would and then your menu is a popup menu from this.  (See GetSubMenu in help)
0
 

Author Comment

by:ulf_k
Comment Utility
But if it's a popup menu there is no widow that owns it. But the popup menu is a window itself.
As i wrote, i coded my own menu class derived form CMenu, this means i won't use the resource editor, cause i have my own way to add items and submenus.

Greetings, -ulf-
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Have a look at this function  CMenu::TrackPopupMenu  it is in the file wincore.cpp.  That is how a popup menu is handled (context menu).  

ps. It does have a parent window - the app.
0
 

Author Comment

by:ulf_k
Comment Utility
Hmm, thanks, but that desn't help me to get the HWND or CWnd* of the menu when it's created.
I don't think a menu is created when displayed and destroyed afterwards.

Greetings, -ulf-
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
The menu exists all the time.  I think the window it is displayed in is purely temporary.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:ulf_k
Comment Utility
so, no chance to get off the beveled border?!

Greetings, -ulf-
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Offhand I don't know how.
0
 

Author Comment

by:ulf_k
Comment Utility
So, nobody knows?!
Then you get the points.
Thanks for trying to help!
Greetings, -ulf-
0
 
LVL 44

Expert Comment

by:AndyAinscow
Comment Utility
Thanks
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
Comment Utility
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now