From 9bd2b4be51e68f4d472bcb6e727ed16d56bb9c91 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Dec 2014 14:24:40 +0000 Subject: [PATCH] Make disabling submenus work in wxMSW. As submenu items don't have a valid ID, we need to address them by their position when calling EnableMenuItem() -- and for simplicity do it for all the items. Closes #16747. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78324 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/menuitem.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 7142c0b896..bf159e981e 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -563,11 +563,12 @@ void wxMenuItem::Enable(bool enable) if ( m_isEnabled == enable ) return; - if ( m_parentMenu ) + const int itemPos = MSGetMenuItemPos(); + if ( itemPos != -1 ) { long rc = EnableMenuItem(GetHMenuOf(m_parentMenu), - GetMSWId(), - MF_BYCOMMAND | + itemPos, + MF_BYPOSITION | (enable ? MF_ENABLED : MF_GRAYED)); if ( rc == -1 )