Solved

Measure a Popup menu

Posted on 1998-12-06
2
448 Views
Last Modified: 2013-11-20
I am trying to measure the width and height of my Popup
menu. I am trying the following code, but with no success.
It does not give me an error but the values of Width
and Height are wrong.

void CPopUpMenuView::OnContextMenu(CWnd* pWnd, CPoint point)
{
      // TODO: Add your message handler code here
      CMenu menu;
      menu.LoadMenu(IDR_MENU1);
      menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|
            TPM_RIGHTBUTTON, point.x, point.y, this);

      MEASUREITEMSTRUCT lpMeasureItemStruct;
      menu.MeasureItem(&lpMeasureItemStruct );
      UINT Width = lpMeasureItemStruct.itemWidth;
      UINT Height = lpMeasureItemStruct.itemHeight;
}
Any ideas?

0
Comment
Question by:Malek103197
2 Comments
 
LVL 2

Accepted Solution

by:
wyy_cq earned 50 total points
ID: 1325800
you can caculate the with from the string width,
and get the height from the system metrics.

Called by the framework when a menu with the owner-draw style is created. By default, this member function does nothing. Override this member function and fill in the MEASUREITEMSTRUCT structure to inform Windows of the menu's dimensions.


0
 

Author Comment

by:Malek103197
ID: 1325801
Thanks for your answer wyy_cq, but I need a little more guidence than you've provided. You state: "you can caculate the width from the string width, and get the height from the system metrics.". How do I calculate the string width of the Popup menu and can you give me more info on using the system metrics. Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Today companies are subjected to more-and-more data, and it won't stop any time soon.  But there are obvious opportunities for reducing data, particularly data duplicated among companies.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

708 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

13 Experts available now in Live!

Get 1:1 Help Now