[PATCH 1/4] regedit: Always assign focus to the default value when refreshing the listview

Hugh McMaster hugh.mcmaster at outlook.com
Mon May 22 08:02:52 CDT 2017


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

diff --git a/programs/regedit/listview.c b/programs/regedit/listview.c
index 11147a7..d8589b8 100644
--- a/programs/regedit/listview.c
+++ b/programs/regedit/listview.c
@@ -109,8 +109,7 @@ static void MakeMULTISZDisplayable(LPWSTR multi)
 /*******************************************************************************
  * Local module support methods
  */
-static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType,
-    void* ValBuf, DWORD dwCount, BOOL bHighlight)
+static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType, void *ValBuf, DWORD dwCount)
 {
     LINE_INFO* linfo;
     LVITEMW item;
@@ -137,9 +136,7 @@ static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType,
     item.stateMask = LVIS_FOCUSED | LVIS_SELECTED;
     item.pszText = Name ? Name : LPSTR_TEXTCALLBACKW;
     item.cchTextMax = Name ? lstrlenW(item.pszText) : 0;
-    if (bHighlight) {
-        item.stateMask = item.state = LVIS_FOCUSED;
-    }
+
     switch (dwValType)
     {
     case REG_SZ:
@@ -552,20 +549,25 @@ 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, !highlightValue);
+        AddEntryToList(hwndLV, NULL, REG_SZ, NULL, 0);
     }
     for(index = 0; index < val_count; index++) {
-        BOOL bSelected = (valName == highlightValue); /* NOT a bug, we check for double NULL here */
         valNameLen = max_val_name_len;
         valSize = max_val_size;
 	valType = 0;
         errCode = RegEnumValueW(hKey, index, valName, &valNameLen, NULL, &valType, valBuf, &valSize);
 	if (errCode != ERROR_SUCCESS) goto done;
         valBuf[valSize] = 0;
-        if (highlightValue && !lstrcmpW(valName, highlightValue))
-            bSelected = TRUE;
-        AddEntryToList(hwndLV, valName[0] ? valName : NULL, valType, valBuf, valSize, bSelected);
+        AddEntryToList(hwndLV, valName[0] ? valName : NULL, valType, valBuf, valSize);
+    }
+
+    memset(&item, 0, sizeof(item));
+    if (!highlightValue)
+    {
+        item.state = item.stateMask = LVIS_FOCUSED;
+        SendMessageW(hwndLV, LVM_SETITEMSTATE, 0, (LPARAM)&item);
     }
+
     SendMessageW(hwndLV, LVM_SORTITEMS, (WPARAM)hwndLV, (LPARAM)CompareFunc);
 
     g_currentRootKey = hKeyRoot;
-- 
2.7.4




More information about the wine-patches mailing list