Nikolay Sivov : regedit: Make it possible for save/ restore position on tree root.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jun 15 08:49:08 CDT 2015
Module: wine
Branch: master
Commit: 6827724e54c49a5f15993ba7e24dddafa68e8502
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6827724e54c49a5f15993ba7e24dddafa68e8502
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sat Jun 13 19:26:22 2015 +0300
regedit: Make it possible for save/restore position on tree root.
---
programs/regedit/childwnd.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/programs/regedit/childwnd.c b/programs/regedit/childwnd.c
index 6dc7d0c..55b11de 100644
--- a/programs/regedit/childwnd.c
+++ b/programs/regedit/childwnd.c
@@ -243,7 +243,14 @@ static void get_last_key(HWND hwndTV)
if (RegCreateKeyExW(HKEY_CURRENT_USER, wszKeyName, 0, NULL, 0, KEY_READ, NULL, &hkey, NULL) == ERROR_SUCCESS)
{
if (RegQueryValueExW(hkey, wszLastKey, NULL, NULL, (LPBYTE)wszVal, &dwSize) == ERROR_SUCCESS)
- SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)FindPathInTree(hwndTV, wszVal));
+ {
+ HTREEITEM selection;
+ if (!strcmpW(wszVal, g_pChildWnd->szPath))
+ selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
+ else
+ selection = FindPathInTree(hwndTV, wszVal);
+ SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)selection);
+ }
RegCloseKey(hkey);
}
@@ -258,15 +265,20 @@ static void get_last_key(HWND hwndTV)
static void set_last_key(HWND hwndTV)
{
HKEY hkey;
- WCHAR *wszVal;
if (RegCreateKeyExW(HKEY_CURRENT_USER, wszKeyName, 0, NULL, 0, KEY_WRITE, NULL, &hkey, NULL) == ERROR_SUCCESS)
{
HTREEITEM selection = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_CARET, 0);
-
- wszVal = GetItemFullPath(g_pChildWnd->hTreeWnd, selection, FALSE);
- RegSetValueExW(hkey, wszLastKey, 0, REG_SZ, (LPBYTE)wszVal, (lstrlenW(wszVal) + 1) * sizeof(WCHAR));
- HeapFree(GetProcessHeap(), 0, wszVal);
+ HTREEITEM root = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_ROOT, 0);
+ WCHAR *value;
+
+ if (selection == root)
+ value = g_pChildWnd->szPath;
+ else
+ value = GetItemFullPath(g_pChildWnd->hTreeWnd, selection, FALSE);
+ RegSetValueExW(hkey, wszLastKey, 0, REG_SZ, (LPBYTE)value, (lstrlenW(value) + 1) * sizeof(WCHAR));
+ if (selection != root)
+ HeapFree(GetProcessHeap(), 0, value);
RegCloseKey(hkey);
}
}
More information about the wine-cvs
mailing list