patch 8.1.0906: using clumsy way to get console window handle
Problem: Using clumsy way to get console window handle.
Solution: Use GetConsoleWindow(). (Ken Takata, closes #3940)
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 8d46e53..8dafaa3 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -1043,11 +1043,6 @@
static void
GetConsoleHwnd(void)
{
-# define MY_BUFSIZE 1024 // Buffer size for console window titles.
-
- char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated WindowTitle.
- char pszOldWindowTitle[MY_BUFSIZE]; // Contains original WindowTitle.
-
/* Skip if it's already set. */
if (s_hwnd != 0)
return;
@@ -1061,17 +1056,7 @@
}
# endif
- GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
-
- wsprintf(pszNewWindowTitle, "%s/%d/%d",
- pszOldWindowTitle,
- GetTickCount(),
- GetCurrentProcessId());
- SetConsoleTitle(pszNewWindowTitle);
- Sleep(40);
- s_hwnd = FindWindow(NULL, pszNewWindowTitle);
-
- SetConsoleTitle(pszOldWindowTitle);
+ s_hwnd = GetConsoleWindow();
}
/*