X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3f8502f7fc4f58ee97cc05adf876c44e04a1498b..13b4df952c77383f50696e51fcbaa2d8bbd3b3b9:/src/msw/menu.cpp diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 543ed55116..3b1871f09d 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -949,18 +949,25 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_) // ignore commands from the menu title if ( id != idMenuTitle ) { + // Default value for uncheckable items. + int checked = -1; + // update the check item when it's clicked wxMenuItem * const item = FindItem(id); if ( item && item->IsCheckable() ) + { item->Toggle(); - // get the status of the menu item: note that it has been just changed - // by Toggle() above so here we already get the new state of the item - // - // Also notice that we must pass unsigned id_ and not sign-extended id - // to ::GetMenuState() as this is what it expects. - UINT menuState = ::GetMenuState(GetHmenu(), id_, MF_BYCOMMAND); - SendEvent(id, menuState & MF_CHECKED); + // Get the status of the menu item: note that it has been just changed + // by Toggle() above so here we already get the new state of the item. + // + // Also notice that we must pass unsigned id_ and not sign-extended id + // to ::GetMenuState() as this is what it expects. + UINT menuState = ::GetMenuState(GetHmenu(), id_, MF_BYCOMMAND); + checked = (menuState & MF_CHECKED) != 0; + } + + SendEvent(id, checked); } return true;