]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dialog.cpp
corrected use of Print Manager Session APIs for Carbon targets
[wxWidgets.git] / src / msw / dialog.cpp
index 4b4259a099378f54778b3151a96fe46e059d6b72..78d54abe46cb44894773e2ea7de2deffed664f0b 100644 (file)
@@ -192,6 +192,36 @@ bool wxDialog::Create(wxWindow *parent,
     return TRUE;
 }
 
+bool wxDialog::EnableCloseButton(bool enable)
+{
+    // 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/enabling the close title bar button
+    if ( !::EnableMenuItem(hmenu, SC_CLOSE,
+                           MF_BYCOMMAND | (enable ? MF_ENABLED : MF_GRAYED)) )
+    {
+        wxLogLastError(_T("DeleteMenu(SC_CLOSE)"));
+
+        return FALSE;
+    }
+
+    // update appearance immediately
+    if ( !::DrawMenuBar(GetHwnd()) )
+    {
+        wxLogLastError(_T("DrawMenuBar"));
+    }
+
+    return TRUE;
+}
+
 void wxDialog::SetModal(bool flag)
 {
     if ( flag )