From 27a239864f78aa1618bb735fae63e0cea2a829cc Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Wed, 3 Apr 2019 15:51:48 +0200 Subject: UI: remove close button from Windows console window. This way you can't accidentally close Blender when toggling the console window to be visible. When Blender is started from the command promt the close button remains. Differential Revision: https://developer.blender.org/D4627 --- intern/ghost/intern/GHOST_SystemWin32.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'intern/ghost') diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index a82d54470af..bf12f049283 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -1704,7 +1704,7 @@ static bool isStartedFromCommandPrompt() } /* When we're starting from a wrapper we need to compare with parent process ID. */ - if (pid == (start_from_launcher ? ppid : GetCurrentProcessId())) + if (pid != (start_from_launcher ? ppid : GetCurrentProcessId())) return true; } @@ -1713,30 +1713,37 @@ static bool isStartedFromCommandPrompt() int GHOST_SystemWin32::toggleConsole(int action) { + HWND wnd = GetConsoleWindow(); + switch (action) { case 3: // startup: hide if not started from command prompt { - if (isStartedFromCommandPrompt()) { - ShowWindow(GetConsoleWindow(), SW_HIDE); + if (!isStartedFromCommandPrompt()) { + ShowWindow(wnd, SW_HIDE); m_consoleStatus = 0; } break; } case 0: // hide - ShowWindow(GetConsoleWindow(), SW_HIDE); + ShowWindow(wnd, SW_HIDE); m_consoleStatus = 0; break; case 1: // show - ShowWindow(GetConsoleWindow(), SW_SHOW); + ShowWindow(wnd, SW_SHOW); + if (!isStartedFromCommandPrompt()) { + DeleteMenu(GetSystemMenu(wnd, FALSE), SC_CLOSE, MF_BYCOMMAND); + } m_consoleStatus = 1; break; case 2: // toggle - ShowWindow(GetConsoleWindow(), m_consoleStatus ? SW_HIDE : SW_SHOW); + ShowWindow(wnd, m_consoleStatus ? SW_HIDE : SW_SHOW); m_consoleStatus = !m_consoleStatus; + if (m_consoleStatus && !isStartedFromCommandPrompt()) { + DeleteMenu(GetSystemMenu(wnd, FALSE), SC_CLOSE, MF_BYCOMMAND); + } break; } - return m_consoleStatus; } -- cgit v1.2.3