From e91a996fa41222805ba2305ee27280a563a0e6e7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Dec 2014 14:17:51 +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/branches/WX_3_0_BRANCH@78323 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/menuitem.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 2eed312fea..49d6909fcf 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -599,6 +599,7 @@ wxMSW: - Fix size of the icon returned from wxFSVolume::GetIcon() (troelsk). - Fix autosize after expanding/collapsing items in wxDataViewCtrl (ciglesias). - Fix inserting tools removed from wxToolBar back into it (sbrowne). +- Fix disabling submenu items in the menus (Artur Wieczorek). 3.0.2: (released 2014-10-06) diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 7d10a044ac..e9ae4e95de 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -557,11 +557,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 )