From d7876f7981ee48a2fdef567a337451429608e73c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Fri, 16 Sep 2005 20:13:26 +0000 Subject: [PATCH] Bletch Partially implemented the treeview right-click menu on Regedit. Just supporting Expand and Collapse for now, and also started work on renaming keys. svn path=/trunk/; revision=17889 --- reactos/subsys/system/regedit/En.rc | 23 ++++++++++ reactos/subsys/system/regedit/childwnd.c | 56 ++++++++++++++++++++++++ reactos/subsys/system/regedit/hexedit.c | 1 + reactos/subsys/system/regedit/main.h | 1 + reactos/subsys/system/regedit/resource.h | 4 ++ reactos/subsys/system/regedit/treeview.c | 2 +- 6 files changed, 86 insertions(+), 1 deletion(-) diff --git a/reactos/subsys/system/regedit/En.rc b/reactos/subsys/system/regedit/En.rc index dca80da4476..b7f11f276c0 100644 --- a/reactos/subsys/system/regedit/En.rc +++ b/reactos/subsys/system/regedit/En.rc @@ -123,6 +123,23 @@ BEGIN 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 @@ BEGIN IDS_INHERIT_SUBKEYSONLY "Subkeys only" END +STRINGTABLE DISCARDABLE +BEGIN + IDS_EXPAND "&Expand" + IDS_COLLAPSE "&Collapse" +END + /*****************************************************************/ diff --git a/reactos/subsys/system/regedit/childwnd.c b/reactos/subsys/system/regedit/childwnd.c index f80f86a8ee8..915deb84cc4 100644 --- a/reactos/subsys/system/regedit/childwnd.c +++ b/reactos/subsys/system/regedit/childwnd.c @@ -110,6 +110,16 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 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 @@ ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 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 @@ ChildWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 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; } diff --git a/reactos/subsys/system/regedit/hexedit.c b/reactos/subsys/system/regedit/hexedit.c index 3859477f25f..dc231d4075e 100644 --- a/reactos/subsys/system/regedit/hexedit.c +++ b/reactos/subsys/system/regedit/hexedit.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "hexedit.h" diff --git a/reactos/subsys/system/regedit/main.h b/reactos/subsys/system/regedit/main.h index 96c6d424686..dcfb374a664 100644 --- a/reactos/subsys/system/regedit/main.h +++ b/reactos/subsys/system/regedit/main.h @@ -35,6 +35,7 @@ #define PM_MODIFYVALUE 0 #define PM_NEW 1 +#define PM_TREECONTEXT 2 extern HINSTANCE hInst; diff --git a/reactos/subsys/system/regedit/resource.h b/reactos/subsys/system/regedit/resource.h index 4de5df11d5b..24dc6571b4f 100644 --- a/reactos/subsys/system/regedit/resource.h +++ b/reactos/subsys/system/regedit/resource.h @@ -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 diff --git a/reactos/subsys/system/regedit/treeview.c b/reactos/subsys/system/regedit/treeview.c index 248af2a4274..f8c221a4fc5 100644 --- a/reactos/subsys/system/regedit/treeview.c +++ b/reactos/subsys/system/regedit/treeview.c @@ -273,7 +273,7 @@ HWND CreateTreeView(HWND hwndParent, LPTSTR pHostName, int id) /* 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. */