[PATCH 2/2] regedit: Only allow value renaming via the Edit or Popup menus

Hugh McMaster hugh.mcmaster at outlook.com
Wed Dec 28 05:47:56 CST 2016


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

diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c
index b9366e5..9b0fcca 100644
--- a/programs/regedit/listview.c
+++ b/programs/regedit/listview.c
@@ -351,12 +351,16 @@ static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSor
 HWND StartValueRename(HWND hwndLV)
 {
     int item;
+    LONG_PTR style;
 
     item = SendMessageW(hwndLV, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0));
     if (item < 1) { /* cannot rename default key */
         MessageBeep(MB_ICONHAND);
         return 0;
     }
+    style = GetWindowLongPtrW(hwndLV, GWL_STYLE);
+    style |= LVS_EDITLABELS;
+    SetWindowLongPtrW(hwndLV, GWL_STYLE, style);
     return (HWND)SendMessageW(hwndLV, LVM_EDITLABELW, item, 0);
 }
 
@@ -403,6 +407,8 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
 	        LPNMLVDISPINFOW dispInfo = (LPNMLVDISPINFOW)lParam;
 		LPWSTR oldName = GetItemText(hWnd, dispInfo->item.iItem);
                 LONG ret;
+                LONG_PTR style;
+
                 if (!oldName) return -1; /* cannot rename a default value */
 	        ret = RenameValue(hWnd, g_currentRootKey, g_currentPath, oldName, dispInfo->item.pszText);
 		if (ret)
@@ -410,6 +416,9 @@ static LRESULT CALLBACK ListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPAR
                     RefreshListView(hWnd, g_currentRootKey, g_currentPath, dispInfo->item.pszText);
                 }
 		HeapFree(GetProcessHeap(), 0, oldName);
+                style = GetWindowLongPtrW(hWnd, GWL_STYLE);
+                style &= ~LVS_EDITLABELS;
+                SetWindowLongPtrW(hWnd, GWL_STYLE, style);
 		return 0;
 	    }
         case NM_RETURN: {
@@ -485,7 +494,7 @@ HWND CreateListView(HWND hwndParent, UINT id)
     /* Get the dimensions of the parent window's client area, and create the list view control.  */
     GetClientRect(hwndParent, &rcClient);
     hwndLV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEWW, ListView,
-                            WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_REPORT | LVS_EDITLABELS,
+                            WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_REPORT,
                             0, 0, rcClient.right, rcClient.bottom,
                             hwndParent, ULongToHandle(id), hInst, NULL);
     if (!hwndLV) return NULL;
-- 
2.7.4




More information about the wine-patches mailing list