From c9c9eafbbb791d1b754c053aac221979a39216e1 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sun, 24 Oct 2010 18:34:08 +0000 Subject: SDL/w32: add ability to hide console feature is currently commented out - waiting till discussion has ended svn-id: r53767 --- backends/platform/sdl/sdl.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 22fc561b0f..21c2c50d79 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -116,6 +116,26 @@ static AspectRatio getDesiredAspectRatio() { } #endif +#if defined(WIN32) + struct SdlConsoleHidingWin32 { + DWORD myPid; + DWORD myTid; + HWND consoleHandle; + }; + + // console hiding for win32 + static BOOL CALLBACK initBackendFindConsoleWin32Proc(HWND hWnd, LPARAM lParam) { + DWORD pid, tid; + SdlConsoleHidingWin32 *variables = (SdlConsoleHidingWin32 *)lParam; + tid = GetWindowThreadProcessId(hWnd, &pid); + if ((tid == variables->myTid) && (pid == variables->myPid)) { + variables->consoleHandle = hWnd; + return FALSE; + } + return TRUE; + } +#endif + void OSystem_SDL::initBackend() { assert(!_inited); @@ -135,6 +155,25 @@ void OSystem_SDL::initBackend() { if (joystick_num > -1) sdlFlags |= SDL_INIT_JOYSTICK; +#if 0 + // NEW CODE TO HIDE CONSOLE FOR WIN32 +#if defined(WIN32) + // console hiding for win32 + SdlConsoleHidingWin32 consoleHidingWin32; + consoleHidingWin32.consoleHandle = 0; + consoleHidingWin32.myPid = GetCurrentProcessId(); + consoleHidingWin32.myTid = GetCurrentThreadId(); + EnumWindows (initBackendFindConsoleWin32Proc, (LPARAM)&consoleHidingWin32); + + if (!ConfMan.getBool("show_console")) { + if (consoleHidingWin32.consoleHandle) { + // We won't find a window with our TID/PID in case we were started from command-line + ShowWindow(consoleHidingWin32.consoleHandle, SW_HIDE); + } + } +#endif +#endif + if (SDL_Init(sdlFlags) == -1) { error("Could not initialize SDL: %s", SDL_GetError()); } -- cgit v1.2.3