From 2aff2f612ac42a9e8b1f79199bfbe9076f7d98e0 Mon Sep 17 00:00:00 2001 From: Hugh McMaster Date: Wed, 31 May 2017 13:07:25 +0000 Subject: [PATCH] regedit: Update handling of the 'Rename' menu item. Signed-off-by: Hugh McMaster Signed-off-by: Alexandre Julliard --- programs/regedit/framewnd.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index f63b1e1fd22..d8f3e6dd595 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -132,23 +132,26 @@ update: SetMenuItemInfoW(hMenu, ID_TREE_EXPAND_COLLAPSE, FALSE, &info); } -static void update_delete_item(HMENU hMenu, WCHAR *keyName) +static void update_delete_and_rename_items(HMENU hMenu, WCHAR *keyName) { - unsigned int state = MF_ENABLED; + unsigned int state_d = MF_ENABLED, state_r = MF_ENABLED; if (!g_pChildWnd->nFocusPanel) { if (!keyName || !*keyName) - state = MF_GRAYED; + state_d = state_r = MF_GRAYED; } else { - if (SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, - MAKELPARAM(LVIS_FOCUSED | LVIS_SELECTED, 0)) == -1) - state = MF_GRAYED; + int index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, + MAKELPARAM(LVIS_FOCUSED | LVIS_SELECTED, 0)); + + if (index == -1) state_d = MF_GRAYED; + if (index < 1) state_r = MF_GRAYED; } - EnableMenuItem(hMenu, ID_EDIT_DELETE, state | MF_BYCOMMAND); + EnableMenuItem(hMenu, ID_EDIT_DELETE, state_d | MF_BYCOMMAND); + EnableMenuItem(hMenu, ID_EDIT_RENAME, state_r | MF_BYCOMMAND); } static void UpdateMenuItems(HMENU hMenu) { @@ -166,8 +169,7 @@ static void UpdateMenuItems(HMENU hMenu) { update_expand_or_collapse_item(hwndTV, selection, hMenu); EnableMenuItem(hMenu, ID_EDIT_MODIFY, (bAllowEdit ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); - update_delete_item(hMenu, keyName); - EnableMenuItem(hMenu, ID_EDIT_RENAME, (bAllowEdit ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); + update_delete_and_rename_items(hMenu, keyName); EnableMenuItem(hMenu, ID_FAVORITES_ADDTOFAVORITES, (hRootKey ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE, (GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);