#include "regedit.h"
-
-#define CX_ICON 16
-#define CY_ICON 16
-#define NUM_ICONS 2
+#define CX_ICON 16
+#define CY_ICON 16
+#define LISTVIEW_NUM_ICONS 2
int Image_String = 0;
int Image_Bin = 0;
static INT g_iSortedColumn = 0;
#define MAX_LIST_COLUMNS (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
-static const int default_column_widths[MAX_LIST_COLUMNS] = { 200, 175, 400 };
+static const int default_column_widths[MAX_LIST_COLUMNS] = { 35, 25, 40 }; /* in percents */
static const int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT };
-LPCWSTR GetValueName(HWND hwndLV, int iStartAt)
+WCHAR *GetValueName(HWND hwndLV, int iStartAt)
{
int item;
LVITEMW LVItem;
{
ListView_SetItemState(hwndLV, i, 0, LVIS_FOCUSED | LVIS_SELECTED);
}
- if (pszValueName == NULL)
+ if (pszValueName == NULL || pszValueName[0] == 0)
i = 0;
else
{
}
ListView_SetItemState(hwndLV, i, LVIS_FOCUSED | LVIS_SELECTED,
LVIS_FOCUSED | LVIS_SELECTED);
+ ListView_EnsureVisible(hwndLV, i, FALSE);
iListViewSelect = i;
}
{
WCHAR buffer[255];
/* load (value not set) string */
- LoadStringW(hInst, IDS_VALUE_NOT_SET, buffer, COUNT_OF(buffer));
+ LoadStringW(hInst, IDS_VALUE_NOT_SET, buffer, ARRAY_SIZE(buffer));
ListView_SetItemText(hwndLV, index, 2, buffer);
}
break;
}
break;
case REG_DWORD:
+ case REG_NONE:
{
WCHAR buf[200];
if(dwCount == sizeof(DWORD))
}
else
{
- LoadStringW(hInst, IDS_INVALID_DWORD, buf, COUNT_OF(buf));
+ LoadStringW(hInst, IDS_INVALID_DWORD, buf, ARRAY_SIZE(buf));
}
ListView_SetItemText(hwndLV, index, 2, buf);
}
else
{
WCHAR szText[128];
- LoadStringW(hInst, IDS_BINARY_EMPTY, szText, COUNT_OF(szText));
+ LoadStringW(hInst, IDS_BINARY_EMPTY, szText, ARRAY_SIZE(szText));
ListView_SetItemText(hwndLV, index, 2, szText);
}
}
}
}
-static BOOL CreateListColumns(HWND hWndListView)
+static BOOL CreateListColumns(HWND hWndListView, INT cxTotal)
{
WCHAR szText[50];
int index;
for (index = 0; index < MAX_LIST_COLUMNS; index++)
{
lvC.iSubItem = index;
- lvC.cx = default_column_widths[index];
+ lvC.cx = (cxTotal * default_column_widths[index]) / 100;
lvC.fmt = column_alignment[index];
- LoadStringW(hInst, IDS_LIST_COLUMN_FIRST + index, szText, COUNT_OF(szText));
+ LoadStringW(hInst, IDS_LIST_COLUMN_FIRST + index, szText, ARRAY_SIZE(szText));
if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) return FALSE;
}
return TRUE;
/* Create the image list. */
if ((himl = ImageList_Create(CX_ICON, CY_ICON,
- ILC_MASK, 0, NUM_ICONS)) == NULL)
+ ILC_MASK, 0, LISTVIEW_NUM_ICONS)) == NULL)
{
return FALSE;
}
Image_String = ImageList_AddIcon(himl, hico);
/* Fail if not all of the images were added. */
- if (ImageList_GetImageCount(himl) < NUM_ICONS)
+ if (ImageList_GetImageCount(himl) < LISTVIEW_NUM_ICONS)
{
return FALSE;
}
switch (plvdi->item.iSubItem)
{
case 0:
- LoadStringW(hInst, IDS_DEFAULT_VALUE_NAME, buffer, COUNT_OF(buffer));
+ LoadStringW(hInst, IDS_DEFAULT_VALUE_NAME, buffer, ARRAY_SIZE(buffer));
plvdi->item.pszText = buffer;
break;
case 1:
default:
{
WCHAR buf2[200];
- LoadStringW(hInst, IDS_UNKNOWN_TYPE, buf2, COUNT_OF(buf2));
+ LoadStringW(hInst, IDS_UNKNOWN_TYPE, buf2, ARRAY_SIZE(buf2));
wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
plvdi->item.pszText = buffer;
break;
return ((int)dw2 - (int)dw1);
}
- case REG_QWORD:
+ case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
{
qw1 = *(DWORDLONG*)l->val;
qw2 = *(DWORDLONG*)r->val;
static BOOL ListView_Sort(HWND hListView, int iSortingColumn, int iSortedColumn)
{
- if ( (GetWindowLongPtr(hListView, GWL_STYLE) & ~LVS_NOSORTHEADER) &&
+ if (!(GetWindowLongPtr(hListView, GWL_STYLE) & LVS_NOSORTHEADER) &&
(iSortingColumn >= 0) )
{
BOOL bSortAscending;
}
return TRUE;
case NM_SETFOCUS:
- g_pChildWnd->nFocusPanel = 0;
+ g_pChildWnd->nFocusPanel = 1;
break;
case LVN_BEGINLABELEDIT:
Info = (NMLVDISPINFO*)lParam;
{
WCHAR msg[128], caption[128];
- LoadStringW(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, COUNT_OF(msg));
- LoadStringW(hInst, IDS_ERR_RENVAL_CAPTION, caption, COUNT_OF(caption));
+ LoadStringW(hInst, IDS_ERR_RENVAL_TOEMPTY, msg, ARRAY_SIZE(msg));
+ LoadStringW(hInst, IDS_ERR_RENVAL_CAPTION, caption, ARRAY_SIZE(caption));
MessageBoxW(0, msg, caption, 0);
*Result = TRUE;
}
return FALSE;
}
-HWND CreateListView(HWND hwndParent, HMENU id)
+HWND CreateListView(HWND hwndParent, HMENU id, INT cx)
{
RECT rcClient;
HWND hwndLV;
if (!hwndLV) return NULL;
/* Initialize the image list, and add items to the control. */
- if (!CreateListColumns(hwndLV)) goto fail;
+ if (!CreateListColumns(hwndLV, cx)) goto fail;
if (!InitListViewImageLists(hwndLV)) goto fail;
return hwndLV;
}
-BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath)
+BOOL RefreshListView(HWND hwndLV, HKEY hKey, LPCWSTR keyPath, BOOL bSelectNone)
{
DWORD max_sub_key_len;
DWORD max_val_name_len;
{
ListView_SetItemState(hwndLV, i, 0, LVIS_FOCUSED | LVIS_SELECTED);
}
+
+ if (bSelectNone)
+ iListViewSelect = -1;
ListView_SetItemState(hwndLV, iListViewSelect,
LVIS_FOCUSED | LVIS_SELECTED,
LVIS_FOCUSED | LVIS_SELECTED);