If I have a default item in my menu and use CCommandBarCtrl::TrackPopupMenu, I get an assert in OnInitMenuPopup.
menuPopup.SetMenuItemInfo returns FALSE. It doesn't like the MF_DEFAULT item state. I'm guessing this state is not allowed to be set directly but one must use the SetMenuDefaultItem function. (like you can't just set WS_VISIBLE, but must call ShowWindow)
To repro this make a menu with a default item either set _WTL_CMDBAR_VISTA_MENUS to 0, or run with Classic theme. Otherwise this code is not used at all (m_bVistaMenus will be true).
My fix is to add:
mii.fState &= ~MF_DEFAULT;
right after this line:
if(!(mii.fType & MFT_OWNERDRAW)) // Not already an ownerdraw item
My tests show that (at least on Windows 7) removing the MF_DEFAULT state does not alter the default menu item, so it looks safe to remove that bit when calling SetMenuItemInfo. More testing is needed to figure out if that's true for all supported platforms.