[PATCH 2/4] regedit: Use the treeview item label in the 'Favourites' menu instead of the key path

Hugh McMaster hugh.mcmaster at outlook.com
Sun Jun 4 19:58:04 CDT 2017


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/regedit/framewnd.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c
index e654d48..7e48513 100644
--- a/programs/regedit/framewnd.c
+++ b/programs/regedit/framewnd.c
@@ -646,15 +646,21 @@ static INT_PTR CALLBACK addtofavorites_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM w
     switch(uMsg) {
         case WM_INITDIALOG:
         {
-            HKEY hKeyRoot = NULL;
-            LPWSTR ItemPath = GetItemPath(g_pChildWnd->hTreeWnd, NULL, &hKeyRoot);
+            HTREEITEM selected;
+            TVITEMW item;
+            WCHAR buf[128];
+
+            selected = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_CARET, 0);
+
+            item.mask = TVIF_HANDLE | TVIF_TEXT;
+            item.hItem = selected;
+            item.pszText = buf;
+            item.cchTextMax = COUNT_OF(buf);
+            SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETITEMW, 0, (LPARAM)&item);
 
-            if(!ItemPath || !*ItemPath)
-                ItemPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, FALSE);
             EnableWindow(GetDlgItem(hwndDlg, IDOK), FALSE);
-            SetWindowTextW(hwndValue, ItemPath);
+            SetWindowTextW(hwndValue, buf);
             SendMessageW(hwndValue, EM_SETLIMITTEXT, 127, 0);
-            HeapFree(GetProcessHeap(), 0, ItemPath);
             return TRUE;
         }
         case WM_COMMAND:
-- 
2.7.4




More information about the wine-patches mailing list