https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2106bc4a8172ba26655d45a564ee0d2d2baa5d44

commit 2106bc4a8172ba26655d45a564ee0d2d2baa5d44
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sat Jun 5 18:21:25 2021 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sat Jun 5 18:21:25 2021 +0900

    [CPL][APPWIZ] Make gecko download cancellable by keyboard (#3726)
    
    We shouldn't disable nor hide the control with focus. CORE-17550, CORE-5737
---
 dll/cpl/appwiz/addons.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/dll/cpl/appwiz/addons.c b/dll/cpl/appwiz/addons.c
index 32e29f9a46f..b9c089f744f 100644
--- a/dll/cpl/appwiz/addons.c
+++ b/dll/cpl/appwiz/addons.c
@@ -388,9 +388,17 @@ static DWORD WINAPI download_proc(PVOID arg)
 
 static INT_PTR CALLBACK installer_proc(HWND hwnd, UINT msg, WPARAM wParam, 
LPARAM lParam)
 {
+    HWND hwndProgress, hwndInstallButton;
     switch(msg) {
     case WM_INITDIALOG:
-        ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_HIDE);
+
+        hwndProgress = GetDlgItem(hwnd, ID_DWL_PROGRESS);
+        if (hwndProgress == GetFocus()) /* Avoid CORE-5737 */
+        {
+            SendMessageW(hwnd, WM_NEXTDLGCTL, 0, FALSE);
+        }
+        ShowWindow(hwndProgress, SW_HIDE);
+
         install_dialog = hwnd;
         return TRUE;
 
@@ -410,7 +418,15 @@ static INT_PTR CALLBACK installer_proc(HWND hwnd, UINT 
msg, WPARAM wParam, LPARA
 
         case ID_DWL_INSTALL:
             ShowWindow(GetDlgItem(hwnd, ID_DWL_PROGRESS), SW_SHOW);
-            EnableWindow(GetDlgItem(hwnd, ID_DWL_INSTALL), 0);
+
+            /* CORE-17550: Never leave focus on a disabled control 
(Old/New/Thing p.228) */
+            hwndInstallButton = GetDlgItem(hwnd, ID_DWL_INSTALL);
+            if (hwndInstallButton == GetFocus())
+            {
+                SendMessageW(hwnd, WM_NEXTDLGCTL, 0, FALSE);
+            }
+            EnableWindow(hwndInstallButton, FALSE);
+
             CloseHandle( CreateThread(NULL, 0, download_proc, NULL, 0, NULL));
             return FALSE;
         }

Reply via email to