[PATCH 3/4] regedit: Select the targeted treeview item on right mouse click

Hugh McMaster hugh.mcmaster at outlook.com
Mon Apr 17 04:15:36 CDT 2017


Fixes bugs 30764 and 37404.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/regedit/childwnd.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/programs/regedit/childwnd.c b/programs/regedit/childwnd.c
index 4d184c3..df7c640 100644
--- a/programs/regedit/childwnd.c
+++ b/programs/regedit/childwnd.c
@@ -372,9 +372,14 @@ LRESULT CALLBACK ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
         break;
 
     case WM_CONTEXTMENU: {
-        int x = GET_X_LPARAM(lParam);
-        int y = GET_Y_LPARAM(lParam);
-        TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW), TPM_RIGHTBUTTON, x, y, 0, hFrameWnd, NULL);
+        POINT pt = {GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)};
+        TVHITTESTINFO ht;
+        ht.pt = pt;
+        ScreenToClient(g_pChildWnd->hTreeWnd, &ht.pt);
+        if (SendMessageW(g_pChildWnd->hTreeWnd, TVM_HITTEST, 0, (LPARAM)&ht))
+            SendMessageW(g_pChildWnd->hTreeWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)ht.hItem);
+        TrackPopupMenu(GetSubMenu(hPopupMenus, PM_NEW), TPM_RIGHTBUTTON,
+                       pt.x, pt.y, 0, hFrameWnd, NULL);
     }
 
     case WM_KEYDOWN:
-- 
2.7.4




More information about the wine-patches mailing list