[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1139
  • Last Modified:

How to get HWND from a CMenu

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
ulf_k
Asked:
ulf_k
  • 5
  • 4
1 Solution
 
AndyAinscowCommented:
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
 
ulf_kAuthor Commented:
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
 
AndyAinscowCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ulf_kAuthor Commented:
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
 
AndyAinscowCommented:
The menu exists all the time.  I think the window it is displayed in is purely temporary.
0
 
ulf_kAuthor Commented:
so, no chance to get off the beveled border?!

Greetings, -ulf-
0
 
AndyAinscowCommented:
Offhand I don't know how.
0
 
ulf_kAuthor Commented:
So, nobody knows?!
Then you get the points.
Thanks for trying to help!
Greetings, -ulf-
0
 
AndyAinscowCommented:
Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now