[ros-diffs] [rharabien] 55593: [COMCTL32] - If no control or one of wizard buttons has focus in PROPSHEET_SetWizButtons, set focus to default wizard button. Tested in Win2k3. Worse fix was already in diff but ...

rharabien at svn.reactos.org rharabien at svn.reactos.org
Tue Feb 14 14:17:18 UTC 2012


Author: rharabien
Date: Tue Feb 14 14:17:18 2012
New Revision: 55593

URL: http://svn.reactos.org/svn/reactos?rev=55593&view=rev
Log:
[COMCTL32]
- If no control or one of wizard buttons has focus in PROPSHEET_SetWizButtons, set focus to default wizard button. Tested in Win2k3. Worse fix was already in diff but wasn't applied.

Modified:
    trunk/reactos/dll/win32/comctl32/comctl32_ros.diff
    trunk/reactos/dll/win32/comctl32/propsheet.c

Modified: trunk/reactos/dll/win32/comctl32/comctl32_ros.diff
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comctl32/comctl32_ros.diff?rev=55593&r1=55592&r2=55593&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comctl32/comctl32_ros.diff [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comctl32/comctl32_ros.diff [iso-8859-1] Tue Feb 14 14:17:18 2012
@@ -125,37 +125,17 @@
 ===================================================================
 --- propsheet.c	(revision 38890)
 +++ propsheet.c	(working copy)
-@@ -2417,6 +2417,29 @@
-   return FALSE;
- }
- 
-+BOOL CALLBACK
-+EnumChildProc(HWND hwnd, LPARAM lParam)
-+{
-+    WCHAR szType[20];
-+    RealGetWindowClassW(hwnd, szType, 20);
-+
-+    if (strcmpW(szType, WC_EDITW) == 0)
-+    {
-+        if (IsWindowEnabled(hwnd) && IsWindowVisible(hwnd))
-+        {
-+            SetFocus(hwnd);
-+            return FALSE;
-+        }
-+    } 
-+    else
-+    {
-+        EnumChildWindows(hwnd, EnumChildProc, 0);
-+    }
-+
-+    return TRUE;
-+}
-+
-+
- /******************************************************************************
-  *            PROPSHEET_SetWizButtons
-  *
-@@ -2438,17 +2461,6 @@
+@@ -2425,6 +2425,9 @@
+   HWND hwndBack   = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
+   HWND hwndNext   = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
+   HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
++  HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL);
++  INT iDefItem = 0;
++  HWND hwndFocus;
+ 
+   TRACE("%d\n", dwFlags);
+ 
+@@ -2432,17 +2435,6 @@
    EnableWindow(hwndNext, FALSE);
    EnableWindow(hwndFinish, FALSE);
  
@@ -173,35 +153,26 @@
    if (dwFlags & PSWIZB_BACK)
      EnableWindow(hwndBack, TRUE);
  
-@@ -2478,6 +2490,31 @@
+@@ -2472,6 +2464,22 @@
    }
    else if (!(dwFlags & PSWIZB_DISABLEDFINISH))
      EnableWindow(hwndFinish, TRUE);
 +
-+  /* set the default pushbutton to an enabled button and give it focus */
++  /* set the default pushbutton to an enabled button */
 +  if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH))
-+  {
-+    SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
-+    SetFocus(hwndFinish);
-+  }
++    iDefItem = IDC_FINISH_BUTTON;
 +  else if (dwFlags & PSWIZB_NEXT)
-+  {
-+    SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
-+    SetFocus(hwndNext);
-+  }
++    iDefItem = IDC_NEXT_BUTTON;
 +  else if (dwFlags & PSWIZB_BACK)
-+  {
-+    SendMessageW(hwndDlg, DM_SETDEFID, IDC_BACK_BUTTON, 0);
-+    SetFocus(hwndBack);
-+  }
++    iDefItem = IDC_BACK_BUTTON;
 +  else
-+  {
-+    SendMessageW(hwndDlg, DM_SETDEFID, IDCANCEL, 0);
-+    SetFocus(GetDlgItem(hwndDlg, IDCANCEL));
-+  }
-+
-+  /* Now try to find an edit control that deserves focus */
-+  EnumChildWindows(PropSheet_GetCurrentPageHwnd(hwndDlg), EnumChildProc, 0);
++    iDefItem = IDCANCEL;
++  SendMessageW(hwndDlg, DM_SETDEFID, iDefItem, 0);
++
++  /* Set focus if no control has it */
++  hwndFocus = GetFocus();
++  if (!hwndFocus || hwndFocus == hwndCancel)
++    SetFocus(GetDlgItem(hwndDlg, iDefItem));
  }
  
  /******************************************************************************

Modified: trunk/reactos/dll/win32/comctl32/propsheet.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comctl32/propsheet.c?rev=55593&r1=55592&r2=55593&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comctl32/propsheet.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comctl32/propsheet.c [iso-8859-1] Tue Feb 14 14:17:18 2012
@@ -2425,23 +2425,15 @@
   HWND hwndBack   = GetDlgItem(hwndDlg, IDC_BACK_BUTTON);
   HWND hwndNext   = GetDlgItem(hwndDlg, IDC_NEXT_BUTTON);
   HWND hwndFinish = GetDlgItem(hwndDlg, IDC_FINISH_BUTTON);
+  HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL);
+  INT iDefItem = 0;
+  HWND hwndFocus;
 
   TRACE("%d\n", dwFlags);
 
   EnableWindow(hwndBack, FALSE);
   EnableWindow(hwndNext, FALSE);
   EnableWindow(hwndFinish, FALSE);
-
-  /* set the default pushbutton to an enabled button */
-  if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH))
-    SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0);
-  else if (dwFlags & PSWIZB_NEXT)
-    SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0);
-  else if (dwFlags & PSWIZB_BACK)
-    SendMessageW(hwndDlg, DM_SETDEFID, IDC_BACK_BUTTON, 0);
-  else
-    SendMessageW(hwndDlg, DM_SETDEFID, IDCANCEL, 0);
-
 
   if (dwFlags & PSWIZB_BACK)
     EnableWindow(hwndBack, TRUE);
@@ -2472,6 +2464,22 @@
   }
   else if (!(dwFlags & PSWIZB_DISABLEDFINISH))
     EnableWindow(hwndFinish, TRUE);
+
+  /* set the default pushbutton to an enabled button */
+  if (((dwFlags & PSWIZB_FINISH) || psInfo->hasFinish) && !(dwFlags & PSWIZB_DISABLEDFINISH))
+    iDefItem = IDC_FINISH_BUTTON;
+  else if (dwFlags & PSWIZB_NEXT)
+    iDefItem = IDC_NEXT_BUTTON;
+  else if (dwFlags & PSWIZB_BACK)
+    iDefItem = IDC_BACK_BUTTON;
+  else
+    iDefItem = IDCANCEL;
+  SendMessageW(hwndDlg, DM_SETDEFID, iDefItem, 0);
+
+  /* Set focus if no control has it */
+  hwndFocus = GetFocus();
+  if (!hwndFocus || hwndFocus == hwndCancel)
+    SetFocus(GetDlgItem(hwndDlg, iDefItem));
 }
 
 /******************************************************************************




More information about the Ros-diffs mailing list