From 9cd1fc3fc4a38d8280bf81af220c75f811748502 Mon Sep 17 00:00:00 2001 From: Hugh McMaster <hugh.mcmaster@outlook.com> Date: Mon, 29 May 2017 08:20:44 +0000 Subject: [PATCH] regedit: Update the data in a listview subitem without refreshing the listview. Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> --- programs/regedit/edit.c | 9 ++++ programs/regedit/framewnd.c | 3 +- programs/regedit/listview.c | 98 +++++++++++++++++++------------------ programs/regedit/main.h | 1 + 4 files changed, 61 insertions(+), 50 deletions(-) diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c index 97a283f3338..fcf2a6061a0 100644 --- a/programs/regedit/edit.c +++ b/programs/regedit/edit.c @@ -373,6 +373,15 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName) error_code_messagebox(hwnd, IDS_UNSUPPORTED_TYPE, type); } + /* Update the listview item with the new data string */ + if (result) + { + int index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, + MAKELPARAM(LVNI_FOCUSED | LVNI_SELECTED, 0)); + stringValueData = read_value(hwnd, hKey, valueName, &type, &len); + format_value_data(g_pChildWnd->hListWnd, index, type, stringValueData, len); + } + done: HeapFree(GetProcessHeap(), 0, stringValueData); stringValueData = NULL; diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index 93a5e4f7b2e..0978cbc713b 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -778,8 +778,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { LPCWSTR valueName = GetValueName(g_pChildWnd->hListWnd); WCHAR* keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot); - if (ModifyValue(hWnd, hKeyRoot, keyPath, valueName)) - RefreshListView(g_pChildWnd->hListWnd, hKeyRoot, keyPath, valueName); + ModifyValue(hWnd, hKeyRoot, keyPath, valueName); HeapFree(GetProcessHeap(), 0, keyPath); break; } diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c index 123949ff27c..caa9a23e56d 100644 --- a/programs/regedit/listview.c +++ b/programs/regedit/listview.c @@ -109,6 +109,54 @@ static void MakeMULTISZDisplayable(LPWSTR multi) /******************************************************************************* * Local module support methods */ +void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD size) +{ + switch (type) + { + case REG_SZ: + case REG_EXPAND_SZ: + ListView_SetItemTextW(hwndLV, index, 2, data ? data : g_szValueNotSet); + break; + case REG_DWORD: + case REG_DWORD_BIG_ENDIAN: + { + DWORD value = *(DWORD *)data; + WCHAR buf[64]; + WCHAR format[] = {'0','x','%','0','8','x',' ','(','%','u',')',0}; + if (type == REG_DWORD_BIG_ENDIAN) + value = RtlUlongByteSwap(value); + wsprintfW(buf, format, value, value); + ListView_SetItemTextW(hwndLV, index, 2, buf); + break; + } + case REG_BINARY: + case REG_NONE: + { + unsigned int i; + BYTE *pData = data; + WCHAR *strBinary = HeapAlloc(GetProcessHeap(), 0, size * sizeof(WCHAR) * 3 + sizeof(WCHAR)); + WCHAR format[] = {'%','0','2','X',' ',0}; + for (i = 0; i < size; i++) + wsprintfW( strBinary + i*3, format, pData[i] ); + strBinary[size * 3] = 0; + ListView_SetItemTextW(hwndLV, index, 2, strBinary); + HeapFree(GetProcessHeap(), 0, strBinary); + break; + } + case REG_MULTI_SZ: + MakeMULTISZDisplayable(data); + ListView_SetItemTextW(hwndLV, index, 2, data); + break; + default: + { + WCHAR szText[128]; + LoadStringW(hInst, IDS_REGISTRY_VALUE_CANT_DISPLAY, szText, COUNT_OF(szText)); + ListView_SetItemTextW(hwndLV, index, 2, szText); + break; + } + } +} + int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWORD dwCount) { LINE_INFO* linfo; @@ -154,54 +202,8 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR item.iIndent = 0; #endif - index = ListView_InsertItemW(hwndLV, &item); - if (index != -1) { - switch (dwValType) { - case REG_SZ: - case REG_EXPAND_SZ: - if (ValBuf) { - ListView_SetItemTextW(hwndLV, index, 2, ValBuf); - } else { - ListView_SetItemTextW(hwndLV, index, 2, g_szValueNotSet); - } - break; - case REG_DWORD: - case REG_DWORD_BIG_ENDIAN: { - DWORD value = *(DWORD*)ValBuf; - WCHAR buf[64]; - WCHAR format[] = {'0','x','%','0','8','x',' ','(','%','u',')',0}; - if (dwValType == REG_DWORD_BIG_ENDIAN) - value = RtlUlongByteSwap(value); - wsprintfW(buf, format, value, value); - ListView_SetItemTextW(hwndLV, index, 2, buf); - } - break; - case REG_BINARY: - case REG_NONE: { - unsigned int i; - LPBYTE pData = ValBuf; - LPWSTR strBinary = HeapAlloc(GetProcessHeap(), 0, dwCount * sizeof(WCHAR) * 3 + sizeof(WCHAR)); - WCHAR format[] = {'%','0','2','X',' ',0}; - for (i = 0; i < dwCount; i++) - wsprintfW( strBinary + i*3, format, pData[i] ); - strBinary[dwCount * 3] = 0; - ListView_SetItemTextW(hwndLV, index, 2, strBinary); - HeapFree(GetProcessHeap(), 0, strBinary); - } - break; - case REG_MULTI_SZ: - MakeMULTISZDisplayable(ValBuf); - ListView_SetItemTextW(hwndLV, index, 2, ValBuf); - break; - default: - { - WCHAR szText[128]; - LoadStringW(hInst, IDS_REGISTRY_VALUE_CANT_DISPLAY, szText, COUNT_OF(szText)); - ListView_SetItemTextW(hwndLV, index, 2, szText); - break; - } - } - } + if ((index = ListView_InsertItemW(hwndLV, &item)) != -1) + format_value_data(hwndLV, index, dwValType, ValBuf, dwCount); return index; } diff --git a/programs/regedit/main.h b/programs/regedit/main.h index b4b030758bd..f09de34239c 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -117,6 +117,7 @@ extern void SetupStatusBar(HWND hWnd, BOOL bResize); extern void UpdateStatusBar(void); /* listview.c */ +extern void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD size); extern int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWORD dwCount); extern HWND CreateListView(HWND hwndParent, UINT id); extern BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highlightValue);