X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/00bc0d1734f114c53674c475d642b9a2f0202448..e3778b4d9c7eebc39f496a9dd055638e06fb9140:/src/msw/msgdlg.cpp?ds=sidebyside diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 9b8440932a..2334638d82 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -18,8 +18,6 @@ #if wxUSE_MSGDLG -#include "wx/ptr_scpd.h" - // there is no hook support under CE so we can't use the code for message box // positioning there #ifndef __WXWINCE__ @@ -29,21 +27,21 @@ #endif #ifndef WX_PRECOMP + #include "wx/msgdlg.h" #include "wx/app.h" #include "wx/intl.h" #include "wx/utils.h" - #include "wx/dialog.h" + #include "wx/msw/private.h" #if wxUSE_MSGBOX_HOOK #include "wx/hashmap.h" #endif #endif +#include "wx/ptr_scpd.h" #include "wx/dynlib.h" -#include "wx/msw/private.h" #include "wx/msw/private/button.h" #include "wx/msw/private/metrics.h" #include "wx/msw/private/msgdlg.h" -#include "wx/msgdlg.h" #if wxUSE_MSGBOX_HOOK #include "wx/fontutil.h" @@ -255,8 +253,10 @@ void wxMessageDialog::ReplaceStaticWithEdit() { if ( *i != '\n' ) { - // found last non-newline char, remove everything after it and stop - text.erase(i.base() + 1, text.end()); + // found last non-newline char, remove anything after it if + // necessary and stop in any case + if ( i != text.rbegin() ) + text.erase(i.base() + 1, text.end()); break; } } @@ -721,16 +721,29 @@ void wxMSWTaskDialogConfig::MSWCommonTaskDialogInit(TASKDIALOGCONFIG &tdc) } else // without Yes/No we're going to have an OK button { - AddTaskDialogButton(tdc, IDOK, TDCBF_OK_BUTTON, btnOKLabel); - if ( style & wxCANCEL ) { + AddTaskDialogButton(tdc, IDOK, TDCBF_OK_BUTTON, btnOKLabel); AddTaskDialogButton(tdc, IDCANCEL, TDCBF_CANCEL_BUTTON, btnCancelLabel); if ( style & wxCANCEL_DEFAULT ) tdc.nDefaultButton = IDCANCEL; } + else // Only "OK" + { + // We actually create a "Cancel" button instead because we want to + // allow closing the dialog box with Escape (and also Alt-F4 or + // clicking the close button in the title bar) which wouldn't work + // without a Cancel button. + if ( !useCustomLabels ) + { + useCustomLabels = true; + btnOKLabel = _("OK"); + } + + AddTaskDialogButton(tdc, IDCANCEL, TDCBF_CANCEL_BUTTON, btnOKLabel); + } } }