Module: wine Branch: master Commit: cb563dbac61c320032ee14bdb2b6def1960393ed URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb563dbac61c320032ee14bdb2...
Author: Hugh McMaster hugh.mcmaster@outlook.com Date: Fri Jun 16 13:06:59 2017 +0000
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
---
programs/regedit/edit.c | 3 ++- programs/regedit/framewnd.c | 15 ++++++++++++++- programs/regedit/listview.c | 8 ++++---- programs/regedit/main.h | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/programs/regedit/edit.c b/programs/regedit/edit.c index d88061c..403def4 100644 --- a/programs/regedit/edit.c +++ b/programs/regedit/edit.c @@ -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); diff --git a/programs/regedit/framewnd.c b/programs/regedit/framewnd.c index 539be96..361da7e 100644 --- a/programs/regedit/framewnd.c +++ b/programs/regedit/framewnd.c @@ -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); diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c index caa9a23..1365259 100644 --- a/programs/regedit/listview.c +++ b/programs/regedit/listview.c @@ -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)); diff --git a/programs/regedit/main.h b/programs/regedit/main.h index f09de34..5331189 100644 --- a/programs/regedit/main.h +++ b/programs/regedit/main.h @@ -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);