
Originally Posted by
chi_luci
ok, now serious.. I think that the framework does not send this message for popups.
Yes it does. Window that owns menu received WM_MEASUREITEM message and calls MeasureItem virtual member of the menu for owner drawn menu items after performing certain checking.
Default implementation of WM_MEASUREITEM handler in CWnd class tries to find menu item ID iterating all menus.
Then it compares itemID member of MEASUREITEMSTRUCT with menu item ID.
Since popup menus do not have ID therefore MEASUREITEMSTRUCT contains handle to a popup instead. Comparison fails and MeasureItem is not called. This also trace message you have posted before.
Override WM_MEASUREITEM in a class that menu is assigned to *** follows:
Code:
void CYourWindowClass::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
if (lpMeasureItemStruct->CtlType == ODT_MENU && lpMeasureItemStruct->itemID == (UINT)m_YourPopup.m_hMenu)
{
m_YourPopup.MeasureItem(lpMeasureItemStruct);
return;
}
CWnd::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}
m_YourPopup is your CMenu derived class type that contains MeasureItem override..