]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed wxMessageBox with only an OK button returning wxCANCEL under MSW.
authorDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Fri, 20 May 2011 22:48:17 +0000 (22:48 +0000)
committerDimitri Schoolwerth <dimitri.schoolwerth@gmail.com>
Fri, 20 May 2011 22:48:17 +0000 (22:48 +0000)
Since r67620 when wxMessageDialog::ShowModal uses a native task dialog and only has an OK button it actually uses a Cancel button, this resulted in the function's return value wrongly changing to wxID_CANCEL. Fix this by handling the special case with only an OK button and return wxID_OK instead of wxID_CANCEL (and thus wxMessageBox, which uses wxMessageDialog::ShowModal, returning wxOK instead of wxCANCEL).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67771 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/msgdlg.cpp

index 2334638d8294480e4f9bb01f7cff302c8445cffa..7c786e51416f78d44d6db7dda540af3c4b8db35e 100644 (file)
@@ -593,6 +593,16 @@ int wxMessageDialog::ShowModal()
             return wxID_CANCEL;
         }
 
+        // In case only an "OK" button was specified we actually created a
+        // "Cancel" button (see comment in MSWCommonTaskDialogInit). This
+        // results in msAns being IDCANCEL while we want IDOK (just like
+        // how the native MessageBox function does with only an "OK" button).
+        if ( (msAns == IDCANCEL)
+            && !(GetMessageDialogStyle() & (wxYES_NO|wxCANCEL)) )
+        {
+            msAns = IDOK;
+        }
+
         return MSWTranslateReturnCode( msAns );
     }
 #endif // wxHAS_MSW_TASKDIALOG