regedit: Re-insert the default value item after deleting its data.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2017-06-16 13:06:59 +00:00 committed by Alexandre Julliard
parent 7f76cf6c26
commit cb563dbac6
4 changed files with 21 additions and 7 deletions

View File

@ -483,7 +483,8 @@ BOOL CreateValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, DWORD valueType, LPW
}
/* Add the new item to the listview */
index = AddEntryToList(g_pChildWnd->hListWnd, valueName, valueType, (BYTE *)&valueDword, sizeof(DWORD));
index = AddEntryToList(g_pChildWnd->hListWnd, valueName, valueType,
(BYTE *)&valueDword, sizeof(DWORD), -1);
item.state = LVIS_FOCUSED | LVIS_SELECTED;
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMSTATE, index, (LPARAM)&item);

View File

@ -806,7 +806,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
HeapFree(GetProcessHeap(), 0, keyPath);
} else if (hWndDelete == g_pChildWnd->hListWnd) {
unsigned int num_selected, index;
unsigned int num_selected, index, focus_idx;
WCHAR *keyPath;
if (!(num_selected = SendMessageW(g_pChildWnd->hListWnd, LVM_GETSELECTEDCOUNT, 0, 0L)))
@ -821,7 +821,9 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
focus_idx = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_FOCUSED, 0));
index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_SELECTED, 0));
while (index != -1)
{
WCHAR *valueName = GetItemText(g_pChildWnd->hListWnd, index);
@ -832,6 +834,17 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
HeapFree(GetProcessHeap(), 0, valueName);
SendMessageW(g_pChildWnd->hListWnd, LVM_DELETEITEM, index, 0L);
/* the default value item is always visible, so add it back in */
if (!index)
{
AddEntryToList(g_pChildWnd->hListWnd, NULL, REG_SZ, NULL, 0, 0);
if (!focus_idx)
{
LVITEMW item;
item.state = item.stateMask = LVIS_FOCUSED;
SendMessageW(g_pChildWnd->hListWnd, LVM_SETITEMSTATE, 0, (LPARAM)&item);
}
}
index = SendMessageW(g_pChildWnd->hListWnd, LVM_GETNEXTITEM, -1, MAKELPARAM(LVNI_SELECTED, 0));
}
HeapFree(GetProcessHeap(), 0, keyPath);

View File

@ -157,7 +157,7 @@ void format_value_data(HWND hwndLV, int index, DWORD type, void *data, DWORD siz
}
}
int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWORD dwCount)
int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWORD dwCount, int pos)
{
LINE_INFO* linfo;
LVITEMW item;
@ -178,7 +178,7 @@ int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWOR
}
item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
item.iItem = SendMessageW(hwndLV, LVM_GETITEMCOUNT, 0, 0);
item.iItem = (pos == -1) ? SendMessageW(hwndLV, LVM_GETITEMCOUNT, 0, 0) : pos;
item.iSubItem = 0;
item.state = 0;
item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
@ -557,7 +557,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
valSize = max_val_size;
if (RegQueryValueExW(hKey, NULL, NULL, &valType, valBuf, &valSize) == ERROR_FILE_NOT_FOUND) {
AddEntryToList(hwndLV, NULL, REG_SZ, NULL, 0);
AddEntryToList(hwndLV, NULL, REG_SZ, NULL, 0, -1);
}
for(index = 0; index < val_count; index++) {
valNameLen = max_val_name_len;
@ -566,7 +566,7 @@ BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highli
errCode = RegEnumValueW(hKey, index, valName, &valNameLen, NULL, &valType, valBuf, &valSize);
if (errCode != ERROR_SUCCESS) goto done;
valBuf[valSize] = 0;
AddEntryToList(hwndLV, valName[0] ? valName : NULL, valType, valBuf, valSize);
AddEntryToList(hwndLV, valName[0] ? valName : NULL, valType, valBuf, valSize, -1);
}
memset(&item, 0, sizeof(item));

View File

@ -118,7 +118,7 @@ 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 int AddEntryToList(HWND hwndLV, WCHAR *Name, DWORD dwValType, void *ValBuf, DWORD dwCount, int pos);
extern HWND CreateListView(HWND hwndParent, UINT id);
extern BOOL RefreshListView(HWND hwndLV, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR highlightValue);
extern HWND StartValueRename(HWND hwndLV);