From: Vadim Zeitlin Date: Tue, 7 Jun 2005 12:06:44 +0000 (+0000) Subject: use stderr in wxMessageOutputBest::Printf() even under Windows if it's available... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/9d03b4eee22027451e6e7c4f3cdea88e9420f5a6?ds=inline use stderr in wxMessageOutputBest::Printf() even under Windows if it's available (patch 1216159) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34564 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/msgout.cpp b/src/common/msgout.cpp index f5642aa6c3..84bb0547e4 100755 --- a/src/common/msgout.cpp +++ b/src/common/msgout.cpp @@ -102,10 +102,17 @@ void wxMessageOutputBest::Printf(const wxChar* format, ...) va_end(args); #ifdef __WINDOWS__ - ::MessageBox(NULL, out, _T("wxWidgets"), MB_ICONINFORMATION | MB_OK); -#else // !__WINDOWS__ - fprintf(stderr, "%s", (const char*) out.mb_str()); + // check if we're running in a console + HANDLE hStdErr = ::GetStdHandle(STD_ERROR_HANDLE); + if ( !hStdErr || hStdErr == INVALID_HANDLE_VALUE ) + { + ::MessageBox(NULL, out, _T("wxWidgets"), MB_ICONINFORMATION | MB_OK); + } + else #endif // __WINDOWS__/!__WINDOWS__ + { + fprintf(stderr, "%s", (const char*) out.mb_str()); + } } // ----------------------------------------------------------------------------