From dc8c61bef78e406080de2be91bc6e8d746edb647 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Fri, 20 May 2011 22:48:17 +0000 Subject: [PATCH] Fixed wxMessageBox with only an OK button returning wxCANCEL under MSW. 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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 2334638d82..7c786e5141 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -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 -- 2.47.2