Solved

How to get HWND from a CMenu

Posted on 2004-08-19
10
1,104 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
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
Creating Labels and Frequency list style reports in SAS code 9 105
Expand data scrubbing tool 13 35
maven archtype selection in eclipse 1 57
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.

820 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