]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/toplevel.cpp
Added ::IsOk() to wxDataStream for error checking in
[wxWidgets.git] / src / msw / toplevel.cpp
index b5da266564757dffea826fadd076040bcfc11028..005d4a78bf4c7625427183f98a605c9a77455466 100644 (file)
@@ -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;
+}
+