Hi,
I'm deriving a class off of the WTL's CCommandBarCtrlImpl in an attempt to
recreate the new look of Office XP or DevStudio.NET. I'm running into a
problem, however, as I cannot seem to get the WM_DRAWITEM message sent to
draw the 'root' menus on the screen ( those which appear at app startup ).
I've overridden the AttachMenu function as follows to change the base menus
to be owner drawn ( the base command bar control doesn't ):
long CCoolMenu::AttachMenu ( HMENU hMenu ) {
ATLASSERT(::IsMenu(hMenu));
for ( int i = 0; i < ::GetMenuItemCount ( hMenu ); i++ ) {
MENUITEMINFO mii;
char menuString [MAX_MENU_STRING];
mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE |
MIIM_SUBMENU | MIIM_TYPE;
mii.fType = MFT_STRING;
mii.dwTypeData = menuString;
mii.cch = MAX_MENU_STRING;
mii.cbSize = sizeof ( mii );
::GetMenuItemInfo ( hMenu, i, TRUE, &mii );
int errorval = GetLastError();
mii.fType = MFT_OWNERDRAW;
::SetMenuItemInfo( hMenu, i, TRUE, &mii );
errorval = GetLastError();
}
CCommandBarCtrlImpl<CCoolMenu>::AttachMenu( hMenu );
return 0;
Quote:
}
This seems to almost work. The errorval variable thrown in to test shows
that the menu is being set without error. The app starts up, and no menu
information is displayed at the top. However, I put breakpoints in the
CCommandCtrlImpl OnDrawItem and OnMeasureItem functions, and they are only
receiving messages when I click to open a submenu. I have also intercepted
the WM_DRAWITEM and WM_MEASUREITEM commands in my own class, with the same
results. So now I am confused. Is it possible to ownerdraw the root menu's
at all? Or will I be forced to do something more drastic?
Thanks, this is starting to give me a headache...
--russell