+ bool bOk;
+
+ wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") );
+ if (m_isChecked == bCheck)
+ return;
+
+ HMENU hMenu = GetHmenuOf(m_parentMenu);
+
+ if (GetKind() == wxITEM_RADIO)
+ {
+ //
+ // It doesn't make sense to uncheck a radio item - what would this do?
+ //
+ if (!bCheck)
+ return;
+
+ //
+ // Get the index of this item in the menu
+ //
+ const wxMenuItemList& rItems = m_parentMenu->GetMenuItems();
+ int nPos = rItems.IndexOf(this);
+
+ wxCHECK_RET( nPos != wxNOT_FOUND
+ ,_T("menuitem not found in the menu items list?")
+ );
+
+ //
+ // Get the radio group range
+ //
+ int nStart;
+ int nEnd;
+
+ if (m_bIsRadioGroupStart)
+ {
+ //
+ // We already have all information we need
+ //
+ nStart = nPos;
+ nEnd = m_vRadioGroup.m_nEnd;
+ }
+ else // next radio group item
+ {
+ //
+ // Get the radio group end from the start item
+ //
+ nStart = m_vRadioGroup.m_nStart;
+ nEnd = rItems.Item(nStart)->GetData()->m_vRadioGroup.m_nEnd;
+ }
+
+ //
+ // Also uncheck all the other items in this radio group
+ //
+ wxMenuItemList::Node* pNode = rItems.Item(nStart);
+
+ for (int n = nStart; n <= nEnd && pNode; n++)
+ {
+ if (n == nPos)
+ {
+ ::WinSendMsg( hMenu
+ ,MM_SETITEMATTR
+ ,MPFROM2SHORT(n, TRUE)
+ ,MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED)
+ );
+ }
+ if (n != nPos)
+ {
+ pNode->GetData()->m_isChecked = FALSE;
+ ::WinSendMsg( hMenu
+ ,MM_SETITEMATTR
+ ,MPFROM2SHORT(n, TRUE)
+ ,MPFROM2SHORT(MIA_CHECKED, FALSE)
+ );
+ }
+ pNode = pNode->GetNext();
+ }
+ }
+ else // check item
+ {
+ if (bCheck)
+ bOk = (bool)::WinSendMsg( hMenu
+ ,MM_SETITEMATTR
+ ,MPFROM2SHORT(GetRealId(), TRUE)
+ ,MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED)
+ );
+ else
+ bOk = (bool)::WinSendMsg( hMenu
+ ,MM_SETITEMATTR
+ ,MPFROM2SHORT(GetRealId(), TRUE)
+ ,MPFROM2SHORT(MIA_CHECKED, FALSE)
+ );