Bletch <npwoods@mess.org>
Partially implemented the treeview right-click menu on Regedit. Just supporting
Expand and Collapse for now, and also started work on renaming keys.
Modified: trunk/reactos/subsys/system/regedit/En.rc
Modified: trunk/reactos/subsys/system/regedit/childwnd.c
Modified: trunk/reactos/subsys/system/regedit/hexedit.c
Modified: trunk/reactos/subsys/system/regedit/main.h
Modified: trunk/reactos/subsys/system/regedit/resource.h
Modified: trunk/reactos/subsys/system/regedit/treeview.c

Modified: trunk/reactos/subsys/system/regedit/En.rc
--- trunk/reactos/subsys/system/regedit/En.rc	2005-09-16 19:47:44 UTC (rev 17888)
+++ trunk/reactos/subsys/system/regedit/En.rc	2005-09-16 20:13:26 UTC (rev 17889)
@@ -123,6 +123,23 @@
             MENUITEM "&DWORD Value",                ID_EDIT_NEW_DWORDVALUE
         END
   END
+  POPUP ""
+  BEGIN
+        MENUITEM "Expand/Collapse",                 ID_TREE_EXPANDBRANCH
+        POPUP "&New"
+        BEGIN
+            MENUITEM "&Key",                        ID_EDIT_NEW_KEY
+            MENUITEM SEPARATOR
+            MENUITEM "&String Value",               ID_EDIT_NEW_STRINGVALUE
+            MENUITEM "&Binary Value",               ID_EDIT_NEW_BINARYVALUE
+            MENUITEM "&DWORD Value",                ID_EDIT_NEW_DWORDVALUE
+        END
+        MENUITEM "&Find",                           ID_EDIT_FIND, GRAYED
+        MENUITEM "&Delete",                         ID_TREE_DELETE
+        MENUITEM "&Rename",                         ID_TREE_RENAME
+        MENUITEM SEPARATOR
+        MENUITEM "&Copy Key Name",                  ID_EDIT_COPYKEYNAME, GRAYED
+  END
 END
 
 
@@ -314,6 +331,12 @@
   IDS_INHERIT_SUBKEYSONLY        "Subkeys only"
 END
 
+STRINGTABLE DISCARDABLE
+BEGIN
+  IDS_EXPAND                     "&Expand"
+  IDS_COLLAPSE                   "&Collapse"
+END
+
 /*****************************************************************/
 
 

Modified: trunk/reactos/subsys/system/regedit/childwnd.c
--- trunk/reactos/subsys/system/regedit/childwnd.c	2005-09-16 19:47:44 UTC (rev 17888)
+++ trunk/reactos/subsys/system/regedit/childwnd.c	2005-09-16 20:13:26 UTC (rev 17889)
@@ -110,6 +110,16 @@
     case ID_VIEW_REFRESH:
         /* TODO */
         break;
+    case ID_TREE_EXPANDBRANCH:
+        TreeView_Expand(pChildWnd->hTreeWnd, TreeView_GetSelection(pChildWnd->hTreeWnd), TVE_EXPAND);
+        break;
+    case ID_TREE_COLLAPSEBRANCH:
+        TreeView_Expand(pChildWnd->hTreeWnd, TreeView_GetSelection(pChildWnd->hTreeWnd), TVE_COLLAPSE);
+        break;
+    case ID_TREE_RENAME:
+        SetFocus(pChildWnd->hTreeWnd);
+        TreeView_EditLabel(pChildWnd->hTreeWnd, TreeView_GetSelection(pChildWnd->hTreeWnd));
+        break;
     case ID_SWITCH_PANELS:
         pChildWnd->nFocusPanel = !pChildWnd->nFocusPanel;
         SetFocus(pChildWnd->nFocusPanel? pChildWnd->hListWnd: pChildWnd->hTreeWnd);
@@ -296,6 +306,13 @@
 	    case NM_SETFOCUS:
 		pChildWnd->nFocusPanel = 0;
 		break;
+            case TVN_ENDLABELEDIT:
+                {
+                  TCHAR msg[32];
+                  _stprintf(msg, _T("rename to %s"), ((NMTVDISPINFO *) lParam)->item.pszText);
+                  MessageBox(pChildWnd->hTreeWnd, msg, NULL, MB_OK);
+                }
+                break;
             default:
                 return 0;
             }
@@ -347,6 +364,45 @@
           TrackPopupMenu(mnu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hFrameWnd, NULL);
         }
       }
+      else if ((HWND)wParam == pChildWnd->hTreeWnd)
+      {
+        TVHITTESTINFO hti;
+        HMENU hContextMenu;
+        TVITEM item;
+        MENUITEMINFO mii;
+        TCHAR buffer[256];
+        LPTSTR s;
+
+        pt = MAKEPOINTS(lParam);
+        hti.pt.x = pt.x;
+        hti.pt.y = pt.y;
+        ScreenToClient(pChildWnd->hTreeWnd, &hti.pt);
+        TreeView_HitTest(pChildWnd->hTreeWnd, &hti);
+
+        if ((hti.flags & TVHT_ONITEM) != 0)
+        {
+          hContextMenu = GetSubMenu(hPopupMenus, PM_TREECONTEXT);
+          TreeView_SelectItem(pChildWnd->hTreeWnd, hti.hItem);
+
+          memset(&item, 0, sizeof(item));
+          item.mask = TVIF_STATE | TVIF_CHILDREN;
+          item.hItem = hti.hItem;
+          TreeView_GetItem(pChildWnd->hTreeWnd, &item);
+
+          LoadString(hInst, (item.state & TVIS_EXPANDED) ? IDS_COLLAPSE : IDS_EXPAND, buffer, sizeof(buffer) / sizeof(buffer[0]));
+
+          memset(&mii, 0, sizeof(mii));
+          mii.cbSize = sizeof(mii);
+          mii.fMask = MIIM_STRING | MIIM_STATE | MIIM_ID;
+          mii.fState = (item.cChildren > 0) ? MFS_DEFAULT : MFS_GRAYED;
+          mii.wID = (item.state & TVIS_EXPANDED) ? ID_TREE_COLLAPSEBRANCH : ID_TREE_EXPANDBRANCH;
+          s = buffer;
+          memcpy(&mii.dwTypeData, &s, sizeof(mii.dwTypeData)); /* arg MinGW */
+          SetMenuItemInfo(hContextMenu, 0, TRUE, &mii);
+
+          TrackPopupMenu(hContextMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, pChildWnd->hWnd, NULL);
+        }
+      }
       break;
     }
 

Modified: trunk/reactos/subsys/system/regedit/hexedit.c
--- trunk/reactos/subsys/system/regedit/hexedit.c	2005-09-16 19:47:44 UTC (rev 17888)
+++ trunk/reactos/subsys/system/regedit/hexedit.c	2005-09-16 20:13:26 UTC (rev 17889)
@@ -24,6 +24,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <tchar.h>
+#include <zmouse.h>
 
 #include "hexedit.h"
 

Modified: trunk/reactos/subsys/system/regedit/main.h
--- trunk/reactos/subsys/system/regedit/main.h	2005-09-16 19:47:44 UTC (rev 17888)
+++ trunk/reactos/subsys/system/regedit/main.h	2005-09-16 20:13:26 UTC (rev 17889)
@@ -35,6 +35,7 @@
 
 #define PM_MODIFYVALUE  0
 #define PM_NEW          1
+#define PM_TREECONTEXT  2
 
 extern HINSTANCE hInst;
 

Modified: trunk/reactos/subsys/system/regedit/resource.h
--- trunk/reactos/subsys/system/regedit/resource.h	2005-09-16 19:47:44 UTC (rev 17888)
+++ trunk/reactos/subsys/system/regedit/resource.h	2005-09-16 20:13:26 UTC (rev 17889)
@@ -128,6 +128,8 @@
 #define IDS_ERR_RENVAL_TOEMPTY		32857
 #define ID_SWITCH_PANELS                32871
 #define ID_EDIT_PERMISSIONS		32872
+#define ID_TREE_DELETE                  32873
+#define ID_TREE_RENAME                  32874
 
 #define IDS_FLT_REGFILES		31001
 #define IDS_FLT_REGFILES_FLT		31002
@@ -152,6 +154,8 @@
 #define IDS_INHERIT_THISKEYONLY		31121
 #define IDS_INHERIT_THISKEYANDSUBKEYS	31122
 #define IDS_INHERIT_SUBKEYSONLY		31123
+#define IDS_EXPAND                      31124
+#define IDS_COLLAPSE                    31125
 
 
 #define IDD_EDIT_STRING			2000

Modified: trunk/reactos/subsys/system/regedit/treeview.c
--- trunk/reactos/subsys/system/regedit/treeview.c	2005-09-16 19:47:44 UTC (rev 17888)
+++ trunk/reactos/subsys/system/regedit/treeview.c	2005-09-16 20:13:26 UTC (rev 17889)
@@ -273,7 +273,7 @@
     /* Get the dimensions of the parent window's client area, and create the tree view control.  */
     GetClientRect(hwndParent, &rcClient);
     hwndTV = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
-                            WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT,
+                            WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_EDITLABELS,
                             0, 0, rcClient.right, rcClient.bottom,
                             hwndParent, (HMENU)id, hInst, NULL);
     /* Initialize the image list, and add items to the control.  */