Solved

Measure a Popup menu

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

726 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