Alistair Leslie-Hughes : regedit: Don' t expand items on initial tree creation.

Alexandre Julliard julliard at winehq.org
Tue Aug 21 16:49:04 CDT 2018


Module: wine
Branch: master
Commit: 006d3f336519289b4d297f080728628c313a5e08
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=006d3f336519289b4d297f080728628c313a5e08

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Mon Aug 20 22:49:20 2018 +0000

regedit: Don't expand items on initial tree creation.

The Message TVM_EXPAND is captured in treeview_notify, then passes
g_pChildWnd->hTreeWnd on to OnTreeExpanding which hasn't been
initialized yet.  The function get_last_key is already called after
the hTreeWnd has been assigned to select the previous selected
item (if it exists).

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/regedit/childwnd.c | 15 ++++++++++-----
 programs/regedit/treeview.c |  3 ---
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/programs/regedit/childwnd.c b/programs/regedit/childwnd.c
index d8431f1..aa690f9 100644
--- a/programs/regedit/childwnd.c
+++ b/programs/regedit/childwnd.c
@@ -240,16 +240,21 @@ static void get_last_key(HWND hwndTV)
 
     if (RegCreateKeyExW(HKEY_CURRENT_USER, wszKeyName, 0, NULL, 0, KEY_READ, NULL, &hkey, NULL) == ERROR_SUCCESS)
     {
+        HTREEITEM selection = NULL;
         if (RegQueryValueExW(hkey, wszLastKey, NULL, NULL, (LPBYTE)wszVal, &dwSize) == ERROR_SUCCESS)
         {
-            HTREEITEM selection;
-            if (!strcmpW(wszVal, g_pChildWnd->szPath))
-                selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
-            else
+            if (strcmpW(wszVal, g_pChildWnd->szPath))
                 selection = FindPathInTree(hwndTV, wszVal);
-            SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)selection);
         }
 
+        if(!selection)
+        {
+            selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
+            SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)selection );
+        }
+        else
+            SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)selection);
+
         RegCloseKey(hkey);
     }
 }
diff --git a/programs/regedit/treeview.c b/programs/regedit/treeview.c
index d5a6767..15a5136 100644
--- a/programs/regedit/treeview.c
+++ b/programs/regedit/treeview.c
@@ -572,9 +572,6 @@ static BOOL InitTreeViewItems(HWND hwndTV, LPWSTR pHostName)
     if (!AddEntryToTree(hwndTV, hRoot, hkcc, HKEY_CURRENT_CONFIG, 1)) return FALSE;
     if (!AddEntryToTree(hwndTV, hRoot, hkdd, HKEY_DYN_DATA, 1)) return FALSE;
 
-    /* expand and select host name */
-    SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hRoot );
-    SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hRoot);
     return TRUE;
 }
 




More information about the wine-cvs mailing list