X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ec4b5290418477d168a9af79ce3f4ec4235317dd..92bdf9f72f6f9aae3de0115b7ac8c6037ef95ca1:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index a4a350915f..ee300d548c 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -62,6 +62,10 @@ // other standard headers #include +#if wxUSE_OWNER_DRAWN && defined(MIIM_BITMAP) + #include "wx/dynlib.h" +#endif + #ifndef MNS_CHECKORBMP #define MNS_CHECKORBMP 0x04000000 #endif @@ -382,7 +386,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) if ( pos == (size_t)-1 ) { // append at the end - pos = ::GetMenuItemCount(GetHmenu()); + pos = GetMenuItemCount(); } BOOL ok = false; @@ -435,10 +439,19 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) // case in wx API WinStruct mi; - mi.fMask = MIM_STYLE; - mi.dwStyle = MNS_CHECKORBMP; - if ( !::SetMenuInfo(GetHmenu(), &mi) ) - wxLogLastError(_T("SetMenuInfo(MNS_NOCHECK)")); + // 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(_T("user32")); + wxDYNLIB_FUNCTION(SetMenuInfo_t, SetMenuInfo, dllUser); + if ( pfnSetMenuInfo ) + { + mi.fMask = MIM_STYLE; + mi.dwStyle = MNS_CHECKORBMP; + if ( !(*pfnSetMenuInfo)(GetHmenu(), &mi) ) + wxLogLastError(_T("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