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@hotmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2018-08-20 22:49:20 +00:00 committed by Alexandre Julliard
parent 760b0de7f4
commit 006d3f3365
2 changed files with 10 additions and 8 deletions

View File

@ -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);
}
}

View File

@ -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;
}