X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/35bf863b1c31c0f1679b214c1b9a742eba918c5e..7eb0e0375fcb0f8d7aab10ef14efe4fca19f681e:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index b5da266564..005d4a78bf 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -601,3 +601,36 @@ void wxTopLevelWindowMSW::SetIcon(const wxIcon& icon) } #endif // __WIN95__ } + +bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) +{ +#ifndef __WXMICROWIN__ + // get system (a.k.a. window) menu + HMENU hmenu = ::GetSystemMenu(GetHwnd(), FALSE /* get it */); + if ( !hmenu ) + { + wxLogLastError(_T("GetSystemMenu")); + + return FALSE; + } + + // enabling/disabling the close item from it also automatically + // disables/enables the close title bar button + if ( !::EnableMenuItem(hmenu, SC_CLOSE, + MF_BYCOMMAND | (enable ? MF_ENABLED : MF_GRAYED)) ) + { + wxLogLastError(_T("EnableMenuItem(SC_CLOSE)")); + + return FALSE; + } + + // update appearance immediately + if ( !::DrawMenuBar(GetHwnd()) ) + { + wxLogLastError(_T("DrawMenuBar")); + } +#endif // !__WXMICROWIN__ + + return TRUE; +} +