changeset 24804:324086c6f757 v8.2.2940

patch 8.2.2940: MS-Windows: cannot see the size when resizing Commit: https://github.com/vim/vim/commit/4f2417ffeedbb687a59a36547e8143724a86bb31 Author: K.Takata <kentkt@csc.jp> Date: Sat Jun 5 16:25:32 2021 +0200 patch 8.2.2940: MS-Windows: cannot see the size when resizing Problem: MS-Windows: cannot see the size of the text area when resizing the gvim window. Solution: Show a tooltip with the text size. (Ken Takata, closes #8326)
author Bram Moolenaar <Bram@vim.org>
date Sat, 05 Jun 2021 16:30:03 +0200
parents ff842afd8e12
children f31e7022526e
files src/gui_w32.c src/version.c
diffstat 2 files changed, 57 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -2942,7 +2942,9 @@ gui_mswin_get_valid_dimensions(
     int w,
     int h,
     int *valid_w,
-    int *valid_h)
+    int *valid_h,
+    int *cols,
+    int *rows)
 {
     int	    base_width, base_height;
 
@@ -2957,10 +2959,10 @@ gui_mswin_get_valid_dimensions(
 	+ gui_mswin_get_menu_height(FALSE)
 #endif
 	;
-    *valid_w = base_width +
-		    ((w - base_width) / gui.char_width) * gui.char_width;
-    *valid_h = base_height +
-		    ((h - base_height) / gui.char_height) * gui.char_height;
+    *cols = (w - base_width) / gui.char_width;
+    *rows = (h - base_height) / gui.char_height;
+    *valid_w = base_width + *cols * gui.char_width;
+    *valid_h = base_height + *rows * gui.char_height;
 }
 
     void
@@ -4480,6 +4482,46 @@ set_tabline_font(void)
 }
 #endif
 
+
+static HWND hwndTip = NULL;
+
+    static void
+show_sizing_tip(int cols, int rows)
+{
+    TOOLINFOA ti = {sizeof(ti)};
+    char buf[32];
+
+    ti.hwnd = s_hwnd;
+    ti.uId = (UINT_PTR)s_hwnd;
+    ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
+    ti.lpszText = buf;
+    sprintf(buf, "%dx%d", cols, rows);
+    if (hwndTip == NULL)
+    {
+	hwndTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL,
+		WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX,
+		CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+		s_hwnd, NULL, GetModuleHandle(NULL), NULL);
+	SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
+	SendMessage(hwndTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);
+    }
+    else
+    {
+	SendMessage(hwndTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
+    }
+    SendMessage(hwndTip, TTM_POPUP, 0, 0);
+}
+
+    static void
+destroy_sizing_tip(void)
+{
+    if (hwndTip != NULL)
+    {
+	DestroyWindow(hwndTip);
+	hwndTip = NULL;
+    }
+}
+
     static int
 _DuringSizing(
     UINT fwSide,
@@ -4488,10 +4530,11 @@ set_tabline_font(void)
     int	    w, h;
     int	    valid_w, valid_h;
     int	    w_offset, h_offset;
+    int	    cols, rows;
 
     w = lprc->right - lprc->left;
     h = lprc->bottom - lprc->top;
-    gui_mswin_get_valid_dimensions(w, h, &valid_w, &valid_h);
+    gui_mswin_get_valid_dimensions(w, h, &valid_w, &valid_h, &cols, &rows);
     w_offset = w - valid_w;
     h_offset = h - valid_h;
 
@@ -4508,6 +4551,8 @@ set_tabline_font(void)
     else if (fwSide == WMSZ_BOTTOM || fwSide == WMSZ_BOTTOMLEFT
 			    || fwSide == WMSZ_BOTTOMRIGHT)
 	lprc->bottom -= h_offset;
+
+    show_sizing_tip(cols, rows);
     return TRUE;
 }
 
@@ -4648,6 +4693,10 @@ set_tabline_font(void)
 	return 0L;
 #endif
 
+    case WM_EXITSIZEMOVE:
+	destroy_sizing_tip();
+	break;
+
     case WM_SIZING:	// HANDLE_MSG doesn't seem to handle this one
 	return _DuringSizing((UINT)wParam, (LPRECT)lParam);
 
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2940,
+/**/
     2939,
 /**/
     2938,