diff --git a/src/main.cpp b/src/main.cpp index 4487b709..c663c8c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,8 +52,16 @@ IMPLEMENT_APP(MSE) /// Write a message to the console if it is available, and to a message box otherwise void write_stdout(const String& str) { bool have_console = false; - #ifndef __WXMSW__ + #ifdef __WXMSW__ // somehow detect whether to use console output + // GetStdHandle sometimes returns an invalid handle instead of INVALID_HANDLE_VALUE + // check with GetHandleInformation + HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + DWORD flags; + bool ok = GetHandleInformation(h,&flags); + if (ok) have_console = true; + #elif __WXGTK__ + have_console = true; // always use console on *nix (?) #endif if (have_console) { wxFileOutputStream file(wxFile::fd_stdout);