From fdfd8efa835e8f7347200315d82784cca9c258ee Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 28 Oct 2017 23:24:51 +0200 Subject: [PATCH] Factor out wxTopLevelWindow::MSWEnableCloseButton() Make it possible to reuse this code for other, non-wx, windows. No real changes, this is just a pure refactoring. --- include/wx/msw/toplevel.h | 3 +++ src/msw/toplevel.cpp | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h index 42c667b9a2..c79754f722 100644 --- a/include/wx/msw/toplevel.h +++ b/include/wx/msw/toplevel.h @@ -90,6 +90,9 @@ public: // NULL if getting the system menu failed. wxMenu *MSWGetSystemMenu() const; + // Enable or disable the close button of the specified window. + static bool MSWEnableCloseButton(WXHWND hwnd, bool enable = true); + // implementation from now on // -------------------------- diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 2b815c74f6..4d7e00cc54 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -986,10 +986,11 @@ void wxTopLevelWindowMSW::SetIcons(const wxIconBundle& icons) DoSelectAndSetIcon(icons, SM_CXICON, SM_CYICON, ICON_BIG); } -bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) +// static +bool wxTopLevelWindowMSW::MSWEnableCloseButton(WXHWND hwnd, bool enable) { // get system (a.k.a. window) menu - HMENU hmenu = GetSystemMenu(GetHwnd(), FALSE /* get it */); + HMENU hmenu = GetSystemMenu(hwnd, FALSE /* get it */); if ( !hmenu ) { // no system menu at all -- ok if we want to remove the close button @@ -1008,7 +1009,7 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) return false; } // update appearance immediately - if ( !::DrawMenuBar(GetHwnd()) ) + if ( !::DrawMenuBar(hwnd) ) { wxLogLastError(wxT("DrawMenuBar")); } @@ -1016,6 +1017,11 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) return true; } +bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) +{ + return MSWEnableCloseButton(GetHwnd(), enable); +} + // Window must have wxCAPTION and either wxCLOSE_BOX or wxSYSTEM_MENU for the // button to be visible. Also check for wxMAXIMIZE_BOX because we don't want // to enable a button that is excluded from the current style.