[PATCH v2] regedit: Add 'Expand' and 'Collapse' options to the treeview pop-up menu
Hugh McMaster
hugh.mcmaster at outlook.com
Wed May 24 05:41:50 CDT 2017
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
Changes since version 1:
- Use ID_TREE_EXPAND_COLLAPSE
- Remove unused bits from item.stateMask
---
programs/regedit/framewnd.c | 42 +++++++++++++++++++++++++++++++++++++++++-
programs/regedit/regedit.rc | 7 +++++++
programs/regedit/resource.h | 3 +++
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c
index 1c4885a..5980794 100644
--- a/programs/regedit/framewnd.c
+++ b/programs/regedit/framewnd.c
@@ -48,6 +48,7 @@ static int searchMask = SEARCH_KEYS | SEARCH_VALUES | SEARCH_CONTENT;
static WCHAR FileNameBuffer[_MAX_PATH];
static WCHAR FileTitleBuffer[_MAX_PATH];
static WCHAR FilterBuffer[_MAX_PATH];
+static WCHAR expandW[16], collapseW[16];
/*******************************************************************************
* Local module support methods
@@ -102,6 +103,35 @@ static void OnExitMenuLoop(HWND hWnd)
UpdateStatusBar();
}
+static void update_expand_or_collapse_item(HWND hwndTV, HTREEITEM selection, HMENU hMenu)
+{
+ TVITEMW item;
+ MENUITEMINFOW info;
+
+ item.hItem = selection;
+ item.mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_STATE;
+ item.stateMask = TVIS_EXPANDED;
+ SendMessageW(hwndTV, TVM_GETITEMW, 0, (LPARAM)&item);
+
+ info.cbSize = sizeof(MENUITEMINFOW);
+ info.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_STATE;
+ info.fType = MFT_STRING;
+ info.fState = MFS_ENABLED;
+ info.dwTypeData = expandW;
+
+ if (!item.cChildren)
+ {
+ info.fState = MFS_GRAYED;
+ goto update;
+ }
+
+ if (item.state & TVIS_EXPANDED)
+ info.dwTypeData = collapseW;
+
+update:
+ SetMenuItemInfoW(hMenu, ID_TREE_EXPAND_COLLAPSE, FALSE, &info);
+}
+
static void UpdateMenuItems(HMENU hMenu) {
HWND hwndTV = g_pChildWnd->hTreeWnd;
BOOL bAllowEdit = FALSE;
@@ -114,6 +144,8 @@ static void UpdateMenuItems(HMENU hMenu) {
if (GetFocus() != hwndTV || (keyName && *keyName)) { /* can't modify root keys, but allow for their values */
bAllowEdit = TRUE;
}
+
+ update_expand_or_collapse_item(hwndTV, selection, hMenu);
EnableMenuItem(hMenu, ID_EDIT_FIND, MF_ENABLED | MF_BYCOMMAND);
EnableMenuItem(hMenu, ID_EDIT_FINDNEXT, MF_ENABLED | MF_BYCOMMAND);
EnableMenuItem(hMenu, ID_EDIT_MODIFY, (bAllowEdit ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
@@ -847,8 +879,14 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
StartValueRename(g_pChildWnd->hListWnd);
}
HeapFree(GetProcessHeap(), 0, keyPath);
- }
break;
+ }
+ case ID_TREE_EXPAND_COLLAPSE:
+ {
+ HTREEITEM selected = (HTREEITEM)SendMessageW(g_pChildWnd->hTreeWnd, TVM_GETNEXTITEM, TVGN_CARET, 0);
+ SendMessageW(g_pChildWnd->hTreeWnd, TVM_EXPAND, TVE_TOGGLE, (LPARAM)selected);
+ break;
+ }
case ID_REGISTRY_PRINTERSETUP:
/*PRINTDLG pd;*/
/*PrintDlg(&pd);*/
@@ -953,6 +991,8 @@ LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
CreateWindowExW(0, szChildClass, captionW, WS_CHILD | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
hWnd, NULL, hInst, 0);
+ LoadStringW(hInst, IDS_EXPAND, expandW, COUNT_OF(expandW));
+ LoadStringW(hInst, IDS_COLLAPSE, collapseW, COUNT_OF(collapseW));
break;
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam))
diff --git a/programs/regedit/regedit.rc b/programs/regedit/regedit.rc
index f480117..89e5e08 100644
--- a/programs/regedit/regedit.rc
+++ b/programs/regedit/regedit.rc
@@ -87,6 +87,7 @@ BEGIN
/* PM_TREEVIEW */
POPUP ""
BEGIN
+ MENUITEM "Expand" ID_TREE_EXPAND_COLLAPSE
POPUP "&New"
BEGIN
MENUITEM "&Key", ID_EDIT_NEW_KEY
@@ -217,6 +218,12 @@ END
STRINGTABLE
BEGIN
+ IDS_EXPAND "Expand"
+ IDS_COLLAPSE "Collapse"
+END
+
+STRINGTABLE
+BEGIN
IDS_REGISTRY_ROOT_NAME "My Computer"
IDS_REGISTRY_DEFAULT_VALUE "(Default)"
IDS_REGISTRY_VALUE_NOT_SET "(value not set)"
diff --git a/programs/regedit/resource.h b/programs/regedit/resource.h
index 5076a7b..88ba12d 100644
--- a/programs/regedit/resource.h
+++ b/programs/regedit/resource.h
@@ -141,6 +141,9 @@
#define ID_EDIT_NEW_EXPANDVALUE 33102
#define IDS_DELETE_KEY_TITLE 33103
#define IDS_DELETE_KEY_TEXT 33104
+#define ID_TREE_EXPAND_COLLAPSE 33105
+#define IDS_EXPAND 33106
+#define IDS_COLLAPSE 33107
#define IDD_EDIT_STRING 2000
#define IDC_VALUE_NAME 2001
--
2.7.4
More information about the wine-patches
mailing list