Solved

Measure a Popup menu

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I need a software suggestion 4 72
Installation of Nessus Professional 5 84
Christmas family picture with greetings 19 84
CD-RW/DVD-ROM DRIVE 3 30
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
Let’s list some of the technologies that enable smooth teleworking. 
Using Adobe Premiere Pro, the viewer will learn how to set up a sequence with proper settings, importing pictures, rendering, and exporting the finished product.
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…

862 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

23 Experts available now in Live!

Get 1:1 Help Now