Revision: 8392 https://osdn.net/projects/ttssh2/scm/svn/commits/8392 Author: zmatsuo Date: 2019-11-22 00:41:32 +0900 (Fri, 22 Nov 2019) Log Message: ----------- コンソールウィンドウの閉じるボタンを無効化した - debugプロパティーページのボタンで再度非表示/表示できるようにした Modified Paths: -------------- branches/unicode_buf/teraterm/teraterm/debug_pp.cpp -------------- next part -------------- Modified: branches/unicode_buf/teraterm/teraterm/debug_pp.cpp =================================================================== --- branches/unicode_buf/teraterm/teraterm/debug_pp.cpp 2019-11-21 15:00:01 UTC (rev 8391) +++ branches/unicode_buf/teraterm/teraterm/debug_pp.cpp 2019-11-21 15:41:32 UTC (rev 8392) @@ -56,6 +56,7 @@ void CDebugPropPage::OnInitDialog() { + // popup SetCheck(IDC_DEBUG_POPUP_ENABLE, UnicodeDebugParam.CodePopupEnable); for (int i = 0; i < _countof(key_list); i++) { const char *key_str = key_list[i].key_str; @@ -68,6 +69,20 @@ SendDlgItemMessageA(IDC_DEBUG_POPUP_KEY2, CB_SETCURSEL, i, 0); } } + + // console button + const char *caption; + HWND hWnd = GetConsoleWindow(); + if (hWnd == NULL) { + caption = "Open console window"; + } else { + if (::IsWindowVisible(hWnd)) { + caption = "Hide console window"; + } else { + caption = "Show console window"; + } + } + SetDlgItemTextA(IDC_DEBUG_CONSOLE_BUTTON, caption); } BOOL CDebugPropPage::OnCommand(WPARAM wParam, LPARAM lParam) @@ -74,10 +89,29 @@ { switch (wParam) { case IDC_DEBUG_CONSOLE_BUTTON | (BN_CLICKED << 16): { - FILE *fp; - AllocConsole(); - freopen_s(&fp, "CONOUT$", "w", stdout); - freopen_s(&fp, "CONOUT$", "w", stderr); + const char *caption; + HWND hWnd = GetConsoleWindow(); + if (hWnd == NULL) { + FILE *fp; + AllocConsole(); + freopen_s(&fp, "CONOUT$", "w", stdout); + freopen_s(&fp, "CONOUT$", "w", stderr); + caption = "Hide console window"; + HWND hWnd = GetConsoleWindow(); + HMENU hmenu = GetSystemMenu(hWnd, FALSE); + RemoveMenu(hmenu, SC_CLOSE, MF_BYCOMMAND); + } + else { + if (::IsWindowVisible(hWnd)) { + ::ShowWindow(hWnd, SW_HIDE); + caption = "Show console window"; + } + else { + ::ShowWindow(hWnd, SW_SHOW); + caption = "Hide console window"; + } + } + SetDlgItemTextA(IDC_DEBUG_CONSOLE_BUTTON, caption); break; } default: