+ // use InsertMenuItem() if possible as it's guaranteed to look
+ // correct while our owner-drawn code is not
+ if ( !mustUseOwnerDrawn )
+ {
+ WinStruct<MENUITEMINFO> mii;
+ mii.fMask = MIIM_STRING | MIIM_DATA;
+
+ // don't set hbmpItem for the checkable items as it would
+ // be used for both checked and unchecked state
+ if ( pItem->IsCheckable() )
+ {
+ mii.fMask |= MIIM_CHECKMARKS;
+ mii.hbmpChecked = GetHBitmapForMenu(pItem, true);
+ mii.hbmpUnchecked = GetHBitmapForMenu(pItem, false);
+ }
+ else if ( pItem->GetBitmap().IsOk() )
+ {
+ mii.fMask |= MIIM_BITMAP;
+ mii.hbmpItem = GetHBitmapForMenu(pItem);
+ }
+
+ mii.cch = itemText.length();
+ mii.dwTypeData = const_cast<wxChar *>(itemText.wx_str());
+
+ if ( flags & MF_POPUP )
+ {
+ mii.fMask |= MIIM_SUBMENU;
+ mii.hSubMenu = GetHmenuOf(pItem->GetSubMenu());
+ }
+ else
+ {
+ mii.fMask |= MIIM_ID;
+ mii.wID = id;
+ }
+
+ mii.dwItemData = reinterpret_cast<ULONG_PTR>(pItem);
+
+ ok = ::InsertMenuItem(GetHmenu(), pos, TRUE /* by pos */, &mii);
+ if ( !ok )
+ {
+ wxLogLastError(wxT("InsertMenuItem()"));
+ }
+ else // InsertMenuItem() ok
+ {
+ // we need to remove the extra indent which is reserved for
+ // the checkboxes by default as it looks ugly unless check
+ // boxes are used together with bitmaps and this is not the
+ // case in wx API
+ WinStruct<MENUINFO> mi;
+
+ // don't call SetMenuInfo() directly, this would prevent
+ // the app from starting up under Windows 95/NT 4
+ typedef BOOL (WINAPI *SetMenuInfo_t)(HMENU, MENUINFO *);
+
+ wxDynamicLibrary dllUser(wxT("user32"));
+ wxDYNLIB_FUNCTION(SetMenuInfo_t, SetMenuInfo, dllUser);
+ if ( pfnSetMenuInfo )
+ {
+ mi.fMask = MIM_STYLE;
+ mi.dwStyle = MNS_CHECKORBMP;
+ if ( !(*pfnSetMenuInfo)(GetHmenu(), &mi) )
+ {
+ wxLogLastError(wxT("SetMenuInfo(MNS_NOCHECK)"));
+ }
+ }
+
+ // tell the item that it's not really owner-drawn but only
+ // needs to draw its bitmap, the rest is done by Windows
+ pItem->SetOwnerDrawn(false);
+ }
+ }
+ }
+#endif // __DMC__