Commit 5ebfcfcb authored by twanvl's avatar twanvl

detect output redirection on windows

parent b07ce1a2
...@@ -52,8 +52,16 @@ IMPLEMENT_APP(MSE) ...@@ -52,8 +52,16 @@ IMPLEMENT_APP(MSE)
/// Write a message to the console if it is available, and to a message box otherwise /// Write a message to the console if it is available, and to a message box otherwise
void write_stdout(const String& str) { void write_stdout(const String& str) {
bool have_console = false; bool have_console = false;
#ifndef __WXMSW__ #ifdef __WXMSW__
// somehow detect whether to use console output // 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 #endif
if (have_console) { if (have_console) {
wxFileOutputStream file(wxFile::fd_stdout); wxFileOutputStream file(wxFile::fd_stdout);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment