Solved

Measure a Popup menu

Posted on 1998-12-06
2
471 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Storage devices are generally used to save the data or sometime transfer the data from one computer system to another system. However, sometimes user accidentally erased their important data from the Storage devices. Users have to know how data reco…
A list of useful business intelligence software.
The viewer will learn how to create multiple layers to apply various filters and how to delete areas from each layer’s filter.
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

773 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