diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 2b65c0142b..5834da9b26 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -526,6 +526,13 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) checkInitially = true; } + // Also handle the case of check menu items that had been checked before + // being attached to the menu: we don't need to actually call Check() on + // them, so we don't use checkInitially in this case, but we do need to + // make them checked at Windows level too. + if ( pItem->IsCheck() && pItem->IsChecked() ) + flags |= MF_CHECKED; + // adjust position to account for the title of a popup menu, if any if ( !GetMenuBar() && !m_title.empty() ) pos += 2; // for the title itself and its separator @@ -611,6 +618,12 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) mii.wID = id; } + if ( flags & MF_CHECKED ) + { + mii.fMask |= MIIM_STATE; + mii.fState = MFS_CHECKED; + } + mii.dwItemData = reinterpret_cast(pItem); ok = ::InsertMenuItem(GetHmenu(), pos, TRUE /* by pos */, &mii);