Mercurial > vim
comparison src/os_mswin.c @ 15798:028c9fdb8469 v8.1.0906
patch 8.1.0906: using clumsy way to get console window handle
commit https://github.com/vim/vim/commit/e1ed53f3f95786c744d4b6c85bda4f476f67cc91
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Feb 12 23:12:37 2019 +0100
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 https://github.com/vim/vim/issues/3940)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 12 Feb 2019 23:15:07 +0100 |
parents | c4efa095f323 |
children | 9745c25da3bc |
comparison
equal
deleted
inserted
replaced
15797:1aa273169f87 | 15798:028c9fdb8469 |
---|---|
1041 * get the window parenting and Z-order to work properly. | 1041 * get the window parenting and Z-order to work properly. |
1042 */ | 1042 */ |
1043 static void | 1043 static void |
1044 GetConsoleHwnd(void) | 1044 GetConsoleHwnd(void) |
1045 { | 1045 { |
1046 # define MY_BUFSIZE 1024 // Buffer size for console window titles. | |
1047 | |
1048 char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated WindowTitle. | |
1049 char pszOldWindowTitle[MY_BUFSIZE]; // Contains original WindowTitle. | |
1050 | |
1051 /* Skip if it's already set. */ | 1046 /* Skip if it's already set. */ |
1052 if (s_hwnd != 0) | 1047 if (s_hwnd != 0) |
1053 return; | 1048 return; |
1054 | 1049 |
1055 # ifdef FEAT_TITLE | 1050 # ifdef FEAT_TITLE |
1059 s_hwnd = g_hWnd; | 1054 s_hwnd = g_hWnd; |
1060 return; | 1055 return; |
1061 } | 1056 } |
1062 # endif | 1057 # endif |
1063 | 1058 |
1064 GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE); | 1059 s_hwnd = GetConsoleWindow(); |
1065 | |
1066 wsprintf(pszNewWindowTitle, "%s/%d/%d", | |
1067 pszOldWindowTitle, | |
1068 GetTickCount(), | |
1069 GetCurrentProcessId()); | |
1070 SetConsoleTitle(pszNewWindowTitle); | |
1071 Sleep(40); | |
1072 s_hwnd = FindWindow(NULL, pszNewWindowTitle); | |
1073 | |
1074 SetConsoleTitle(pszOldWindowTitle); | |
1075 } | 1060 } |
1076 | 1061 |
1077 /* | 1062 /* |
1078 * Console implementation of ":winpos". | 1063 * Console implementation of ":winpos". |
1079 */ | 1064 */ |