The information in this article applies to:
SYMPTOMSThe CMenu::MeasureItem() function for an owner-draw menu isn't called for those menu items that bring up submenus. CAUSEThis is a limitation of the self-drawing capability of MFC owner-draw menus. RESOLUTIONFor owner-draw menus that contain sub-popup menus, handle the WM_MEASUREITEM in the owning window. See the "Sample Code" section in this article for an example. STATUSThis behavior is by design. MORE INFORMATION
A menu item that brings up a submenu has no real ID associated with it.
Instead the ID for this popup placeholder is actually the HMENU for the
submenu associated with that item. As for all owner-draw menu items,
Windows will send a WM_MEASUREITEM message to the application, specifying
the address of a MEASUREITEMSTRUCT structure in lParam. The application
should fill in this structure with the dimensions of the menu item. Now
because the submenu item has an HMENU instead of an ID, this is the value
that is passed in the idFrom variable of this structure. Essentially, an
application that handles this message must recognize when this is an HWND
for a valid submenu item. As of MFC 4.0, MFC's implementation of
CWnd::OnMeasureItem() does not make this determination correctly. Sample CodeThe following sample code demonstrates how to implement OnMeasureItem when the menu item in question is a submenu. m_hMenuSub is a member variable that was initialized when the menu was created. If the item is not a submenu, the MFC self-drawing menu code can still be used.
© Microsoft Corporation 1999, All Rights Reserved. Additional query words: 1.00 1.50 2.50 2.51 2.52 2.00 2.10 2.20 3.00 3.10 3.20 4.00
Keywords : kbcode kbMFC KbUIDesign kbVC |
Last Reviewed: December 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |