X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/35bf863b1c31c0f1679b214c1b9a742eba918c5e..51072df23ffcf5bdd4651dbe0ad5143b1e360119:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index b5da266564..6c7b38718b 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -258,7 +258,7 @@ bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate, // and passing CW_USEDEFAULT to MoveWindow() results in resizing the // window to (0, 0) size which breaks quite a lot of things, e.g. the // sizer calculation in wxSizer::Fit() - if ( w == CW_USEDEFAULT ) + if ( w == (int)CW_USEDEFAULT ) { // the exact number doesn't matter, the dialog will be resized // again soon anyhow but it should be big enough to allow @@ -268,7 +268,7 @@ bool wxTopLevelWindowMSW::CreateDialog(const wxChar *dlgTemplate, h = 100; } - if ( x == CW_USEDEFAULT ) + if ( x == (int)CW_USEDEFAULT ) { // well, where should we put it? maybe centre it on screen? x = @@ -601,3 +601,37 @@ 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)) == -1 ) + { + wxLogLastError(_T("EnableMenuItem(SC_CLOSE)")); + + return FALSE; + } + + // update appearance immediately + if ( !::DrawMenuBar(GetHwnd()) ) + { + wxLogLastError(_T("DrawMenuBar")); + } +#endif // !__WXMICROWIN__ + + return TRUE; +} +