From b3bf849a892f24825c53ee44b97e5437cf1c97a5 Mon Sep 17 00:00:00 2001 From: aquanull Date: Mon, 22 Apr 2013 02:59:27 +0800 Subject: [PATCH] Fix showing/hiding Log Console on Windows It appears to me that sometimes the first call to ShowWindow() is hindered by STARTUPINFO or something, so I just "neutralize" them with a dummy call. There might be better solutions, but this works for now. --- Common/ConsoleListener.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index 24ae9672b1..59022f020a 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -79,8 +79,10 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title { // Open the console window and create the window handle for GetStdHandle() AllocConsole(); + HWND hConWnd = GetConsoleWindow(); + ShowWindow(hConWnd, SW_SHOWDEFAULT); // Hide - if (Hidden) ShowWindow(GetConsoleWindow(), SW_HIDE); + if (Hidden) ShowWindow(hConWnd, SW_HIDE); // Save the window handle that AllocConsole() created hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Set the console window title