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
This commit is contained in:
Dimitri Schoolwerth
2011-05-20 22:48:17 +00:00
parent 1667f96a85
commit dc8c61bef7

View 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