From: Yasuhiro Matsumoto Date: Thu, 19 Mar 2026 21:40:25 +0000 (+0000) Subject: patch 9.2.0207: MS-Windows: freeze on second :hardcopy X-Git-Tag: v9.2.0207^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6391a38e5e88ac97f2d39fdcb35392b8eed67bc4;p=thirdparty%2Fvim.git patch 9.2.0207: MS-Windows: freeze on second :hardcopy Problem: MS-Windows: freeze on second :hardcopy (antoniopaolini) Solution: Enable PrintHookProc in GUI mode to ensure the print dialog is brought to the foreground (Yasuhiro Matsumoto). Enable PrintHookProc for GUI mode so that the print dialog is brought to the foreground via BringWindowToTop/SetForegroundWindow. Without the hook, the second PrintDlgW() modal dialog appears behind gvim due to Windows foreground lock timeout, making gvim unresponsive. Also add NULL checks for hDlgPrint in SendMessage calls. fixes: #19715 closes: #19754 Signed-off-by: Yasuhiro Matsumoto Signed-off-by: Christian Brabandt --- diff --git a/src/os_mswin.c b/src/os_mswin.c index 89e4d1c4dd..6c92428a0a 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -1192,8 +1192,6 @@ AbortProc(HDC hdcPrn UNUSED, int iCode UNUSED) return !*bUserAbort; } -# if !defined(FEAT_GUI) || defined(VIMDLL) - static UINT_PTR CALLBACK PrintHookProc( HWND hDlg, // handle to dialog box @@ -1246,7 +1244,6 @@ PrintHookProc( return FALSE; } -# endif void mch_print_cleanup(void) @@ -1262,7 +1259,7 @@ mch_print_cleanup(void) if (prt_dlg.hDC != NULL) DeleteDC(prt_dlg.hDC); - if (!*bUserAbort) + if (!*bUserAbort && hDlgPrint != NULL) SendMessage(hDlgPrint, WM_COMMAND, 0, 0); } @@ -1400,18 +1397,11 @@ mch_print_init(prt_settings_T *psettings, char_u *jobname, int forceit) prt_dlg.hDevMode = stored_dm; prt_dlg.hDevNames = stored_devn; prt_dlg.lCustData = stored_nCopies; // work around bug in print dialog -# if !defined(FEAT_GUI) || defined(VIMDLL) -# ifdef VIMDLL - if (!gui.in_use) -# endif - { - /* - * Use hook to prevent console window being sent to back - */ - prt_dlg.lpfnPrintHook = PrintHookProc; - prt_dlg.Flags |= PD_ENABLEPRINTHOOK; - } -# endif + /* + * Use hook to prevent print dialog being sent to back. + */ + prt_dlg.lpfnPrintHook = PrintHookProc; + prt_dlg.Flags |= PD_ENABLEPRINTHOOK; prt_dlg.Flags |= stored_nFlags; } @@ -1628,7 +1618,7 @@ mch_print_begin(prt_settings_T *psettings) mch_print_end(prt_settings_T *psettings UNUSED) { EndDoc(prt_dlg.hDC); - if (!*bUserAbort) + if (!*bUserAbort && hDlgPrint != NULL) SendMessage(hDlgPrint, WM_COMMAND, 0, 0); } diff --git a/src/version.c b/src/version.c index 6914a9b5dd..7482aa8b71 100644 --- a/src/version.c +++ b/src/version.c @@ -734,6 +734,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 207, /**/ 206, /**/