?
Solved

How to get HWND from a CMenu

Posted on 2004-08-19
10
Medium Priority
?
1,124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 180 total points
ID: 11840097
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
ID: 11840126
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
ID: 11840192
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ulf_k
ID: 11840474
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
ID: 11840490
The menu exists all the time.  I think the window it is displayed in is purely temporary.
0
 

Author Comment

by:ulf_k
ID: 11840780
so, no chance to get off the beveled border?!

Greetings, -ulf-
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 11841172
Offhand I don't know how.
0
 

Author Comment

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

Expert Comment

by:AndyAinscow
ID: 11870026
Thanks
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 11870276
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

801 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