From 9907ca13f9baa04f5d4cc3d5b6bc13d1fdbf147e Mon Sep 17 00:00:00 2001 From: utelle Date: Fri, 31 Aug 2018 16:23:05 +0200 Subject: [PATCH] Fix issue with MDI window menu label If the locale is changed while the MDI window menu is active, the menubar entry labelled with the previous translation will not be removed. The previous translation is now remembered and used to locate the menubar entry. --- src/msw/mdi.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index b520a01bb0..a5cc0e98a4 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -77,6 +77,7 @@ const int wxID_MDI_MORE_WINDOWS = wxLAST_MDI_CHILD + 1; // The MDI "Window" menu label const char *WINDOW_MENU_LABEL = gettext_noop("&Window"); +wxString WINDOW_MENU_LABEL_TRANSLATED; // --------------------------------------------------------------------------- // private functions @@ -1562,6 +1563,7 @@ void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin) bool inserted = false; wxString buf; MenuIterator it(hmenu); + WINDOW_MENU_LABEL_TRANSLATED = wxGetTranslation(WINDOW_MENU_LABEL); while ( it.GetNext(buf) ) { const wxString label = wxStripMenuCodes(buf); @@ -1571,7 +1573,7 @@ void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin) ::InsertMenu(hmenu, it.GetPos(), MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)menuWin, - wxString(wxGetTranslation(WINDOW_MENU_LABEL)).t_str()); + WINDOW_MENU_LABEL_TRANSLATED.t_str()); break; } } @@ -1580,7 +1582,7 @@ void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin) { ::AppendMenu(hmenu, MF_POPUP, (UINT_PTR)menuWin, - wxString(wxGetTranslation(WINDOW_MENU_LABEL)).t_str()); + WINDOW_MENU_LABEL_TRANSLATED.t_str()); } } @@ -1597,7 +1599,7 @@ void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu) MenuIterator it(hmenu); while ( it.GetNext(buf) ) { - if ( wxStrcmp(buf, wxGetTranslation(WINDOW_MENU_LABEL)) == 0 ) + if ( wxStrcmp(buf, WINDOW_MENU_LABEL_TRANSLATED) == 0 ) { if ( !::RemoveMenu(hmenu, it.GetPos(), MF_BYPOSITION) ) {