mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-11 13:17:00 -04:00
detect output redirection on windows
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1049 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+9
-1
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user