ReactOS 0.4.16-dev-197-g92996da
listview.c File Reference
#include "regedit.h"
Include dependency graph for listview.c:

Go to the source code of this file.

Classes

struct  tagLINE_INFO
 
struct  tagSORT_INFO
 

Macros

#define CX_ICON   16
 
#define CY_ICON   16
 
#define LISTVIEW_NUM_ICONS   2
 
#define MAX_LIST_COLUMNS   (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)
 

Typedefs

typedef struct tagLINE_INFO LINE_INFO
 
typedef struct tagLINE_INFOPLINE_INFO
 
typedef struct tagSORT_INFO SORT_INFO
 
typedef struct tagSORT_INFOPSORT_INFO
 

Functions

WCHARGetValueName (HWND hwndLV, int iStartAt)
 
VOID SetValueName (HWND hwndLV, LPCWSTR pszValueName)
 
BOOL IsDefaultValue (HWND hwndLV, int i)
 
static void AddEntryToList (HWND hwndLV, LPWSTR Name, DWORD dwValType, void *ValBuf, DWORD dwCount, int Position, BOOL ValExists)
 
static BOOL CreateListColumns (HWND hWndListView, INT cxTotal)
 
static BOOL InitListViewImageLists (HWND hwndLV)
 
static void OnGetDispInfo (NMLVDISPINFO *plvdi)
 
static int CALLBACK CompareFunc (LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
 
static BOOL ListView_Sort (HWND hListView, int iSortingColumn, int iSortedColumn)
 
BOOL ListWndNotifyProc (HWND hWnd, WPARAM wParam, LPARAM lParam, BOOL *Result)
 
HWND CreateListView (HWND hwndParent, HMENU id, INT cx)
 
void DestroyListView (HWND hwndLV)
 
BOOL RefreshListView (HWND hwndLV, HKEY hKey, LPCWSTR keyPath, BOOL bSelectNone)
 

Variables

int Image_String
 
int Image_Bin
 
INT iListViewSelect = -1
 
static INT g_iSortedColumn
 
static const int default_column_widths [MAX_LIST_COLUMNS] = { 35, 25, 40 }
 
static const int column_alignment [MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT }
 

Macro Definition Documentation

◆ CX_ICON

#define CX_ICON   16

Definition at line 10 of file listview.c.

◆ CY_ICON

#define CY_ICON   16

Definition at line 11 of file listview.c.

◆ LISTVIEW_NUM_ICONS

#define LISTVIEW_NUM_ICONS   2

Definition at line 12 of file listview.c.

◆ MAX_LIST_COLUMNS

#define MAX_LIST_COLUMNS   (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)

Definition at line 38 of file listview.c.

Typedef Documentation

◆ LINE_INFO

◆ PLINE_INFO

◆ PSORT_INFO

◆ SORT_INFO

Function Documentation

◆ AddEntryToList()

static void AddEntryToList ( HWND  hwndLV,
LPWSTR  Name,
DWORD  dwValType,
void ValBuf,
DWORD  dwCount,
int  Position,
BOOL  ValExists 
)
static

Definition at line 113 of file listview.c.

114{
115 PLINE_INFO linfo;
117 int index;
118
119 linfo = (PLINE_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINE_INFO) + dwCount);
120 linfo->dwValType = dwValType;
121 linfo->val_len = dwCount;
122 if (dwCount > 0)
123 {
124 memcpy(&linfo[1], ValBuf, dwCount);
125 linfo->val = &linfo[1];
126 }
127 linfo->name = _wcsdup(Name);
128
130 item.iItem = (Position == -1 ? 0: Position);
131 item.iSubItem = 0;
132 item.state = 0;
133 item.stateMask = 0;
134 item.pszText = Name;
135 item.cchTextMax = (int)wcslen(item.pszText);
136 if (item.cchTextMax == 0)
137 item.pszText = LPSTR_TEXTCALLBACK;
138 item.iImage = 0;
139 item.lParam = (LPARAM)linfo;
140 switch(dwValType)
141 {
142 case REG_SZ:
143 case REG_EXPAND_SZ:
144 case REG_MULTI_SZ:
145 item.iImage = Image_String;
146 break;
147 default:
148 item.iImage = Image_Bin;
149 break;
150 }
151
152 /* item.lParam = (LPARAM)ValBuf; */
153#if (_WIN32_IE >= 0x0300)
154 item.iIndent = 0;
155#endif
156
157 index = ListView_InsertItem(hwndLV, &item);
158 if (index != -1)
159 {
160 switch (dwValType)
161 {
162 case REG_SZ:
163 case REG_EXPAND_SZ:
164 if(dwCount > 0)
165 {
166 ListView_SetItemText(hwndLV, index, 2, ValBuf);
167 }
168 else if(!ValExists)
169 {
170 WCHAR buffer[255];
171 /* load (value not set) string */
173 ListView_SetItemText(hwndLV, index, 2, buffer);
174 }
175 break;
176 case REG_MULTI_SZ:
177 {
178 LPWSTR src, str;
179 if(dwCount >= 2)
180 {
181 src = (LPWSTR)ValBuf;
182 str = HeapAlloc(GetProcessHeap(), 0, dwCount + sizeof(WCHAR));
183 if(str != NULL)
184 {
185 *str = L'\0';
186 /* concatenate all srings */
187 while(*src != L'\0')
188 {
189 wcscat(str, src);
190 wcscat(str, L" ");
191 src += wcslen(src) + 1;
192 }
193 ListView_SetItemText(hwndLV, index, 2, str);
195 }
196 else
197 ListView_SetItemText(hwndLV, index, 2, L"");
198 }
199 else
200 ListView_SetItemText(hwndLV, index, 2, L"");
201 }
202 break;
203 case REG_DWORD:
204 {
205 WCHAR buf[200];
206 if(dwCount == sizeof(DWORD))
207 {
208 wsprintf(buf, L"0x%08x (%u)", *(DWORD*)ValBuf, *(DWORD*)ValBuf);
209 }
210 else
211 {
213 }
214 ListView_SetItemText(hwndLV, index, 2, buf);
215 }
216 /* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
217 break;
218 default: /* REG_BINARY, REG_NONE etc. */
219 {
220 unsigned int i;
221 LPBYTE pData = (LPBYTE)ValBuf;
222 LPWSTR strBinary;
223 if(dwCount > 0)
224 {
225 strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(WCHAR) * 3) + sizeof(WCHAR));
226 for (i = 0; i < dwCount; i++)
227 {
228 wsprintf( strBinary + i*3, L"%02X ", pData[i] );
229 }
230 strBinary[dwCount * 3] = 0;
231 ListView_SetItemText(hwndLV, index, 2, strBinary);
232 HeapFree(GetProcessHeap(), 0, strBinary);
233 }
234 else
235 {
236 WCHAR szText[128];
237 LoadStringW(hInst, IDS_BINARY_EMPTY, szText, ARRAY_SIZE(szText));
238 ListView_SetItemText(hwndLV, index, 2, szText);
239 }
240 }
241 break;
242 }
243 }
244}
struct NameRec_ * Name
Definition: cdprocs.h:460
#define index(s, c)
Definition: various.h:29
struct tagLINE_INFO LINE_INFO
int Image_String
Definition: listview.c:14
struct tagLINE_INFO * PLINE_INFO
int Image_Bin
Definition: listview.c:15
#define ARRAY_SIZE(A)
Definition: main.h:20
#define IDS_BINARY_EMPTY
Definition: resource.h:78
#define IDS_VALUE_NOT_SET
Definition: resource.h:80
#define IDS_INVALID_DWORD
Definition: resource.h:85
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum src
Definition: glext.h:6340
GLuint buffer
Definition: glext.h:5915
GLuint index
Definition: glext.h:6031
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static ATOM item
Definition: dde.c:856
#define REG_MULTI_SZ
Definition: nt_native.h:1501
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define L(x)
Definition: ntvdm.h:50
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2413
#define LPSTR_TEXTCALLBACK
Definition: commctrl.h:2388
#define LVIF_PARAM
Definition: commctrl.h:2316
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2696
#define LVIF_TEXT
Definition: commctrl.h:2314
#define LVIF_IMAGE
Definition: commctrl.h:2315
const WCHAR * str
#define REG_DWORD
Definition: sdbapi.c:596
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
DWORD dwValType
Definition: listview.c:20
void * val
Definition: listview.c:22
LPWSTR name
Definition: listview.c:21
size_t val_len
Definition: listview.c:23
static COORD Position
Definition: mouse.c:34
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
unsigned char * LPBYTE
Definition: typedefs.h:53
LONG_PTR LPARAM
Definition: windef.h:208
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define wsprintf
Definition: winuser.h:5877
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by RefreshListView().

◆ CompareFunc()

static int CALLBACK CompareFunc ( LPARAM  lParam1,
LPARAM  lParam2,
LPARAM  lParamSort 
)
static

Definition at line 368 of file listview.c.

369{
370 PSORT_INFO pSortInfo = (PSORT_INFO)lParamSort;
371 LINE_INFO *l, *r;
372 DWORD dw1, dw2;
373 DWORDLONG qw1, qw2;
374
375 l = (LINE_INFO*)lParam1;
376 r = (LINE_INFO*)lParam2;
377
378 if (pSortInfo->iSortingColumn == 1 && l->dwValType != r->dwValType)
379 {
380 /* Sort by type */
381 if (pSortInfo->bSortAscending)
382 return ((int)l->dwValType - (int)r->dwValType);
383 else
384 return ((int)r->dwValType - (int)l->dwValType);
385 }
386 if (pSortInfo->iSortingColumn == 2)
387 {
388 /* Sort by value */
389 if (l->dwValType != r->dwValType)
390 {
391 if (pSortInfo->bSortAscending)
392 return ((int)l->dwValType - (int)r->dwValType);
393 else
394 return ((int)r->dwValType - (int)l->dwValType);
395 }
396
397 if (l->val == NULL && r->val == NULL)
398 return 0;
399
400 if (pSortInfo->bSortAscending)
401 {
402 if (l->val == NULL)
403 return -1;
404 if (r->val == NULL)
405 return 1;
406 }
407 else
408 {
409 if (l->val == NULL)
410 return 1;
411 if (r->val == NULL)
412 return -1;
413 }
414
415 switch(l->dwValType)
416 {
417 case REG_DWORD:
418 {
419 dw1 = *(DWORD*)l->val;
420 dw2 = *(DWORD*)r->val;
421 if (pSortInfo->bSortAscending)
422 // return (dw1 > dw2 ? 1 : -1);
423 return ((int)dw1 - (int)dw2);
424 else
425 // return (dw1 > dw2 ? -1 : 1);
426 return ((int)dw2 - (int)dw1);
427 }
428
429 case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
430 {
431 qw1 = *(DWORDLONG*)l->val;
432 qw2 = *(DWORDLONG*)r->val;
433 if (pSortInfo->bSortAscending)
434 // return (qw1 > qw2 ? 1 : -1);
435 return ((int)qw1 - (int)qw2);
436 else
437 // return (qw1 > qw2 ? -1 : 1);
438 return ((int)qw2 - (int)qw1);
439 }
440
441 default:
442 {
443 INT nCompare = 0;
444
445 if (pSortInfo->bSortAscending)
446 {
447 nCompare = memcmp(l->val, r->val, min(l->val_len, r->val_len));
448 if (nCompare == 0)
449 nCompare = l->val_len - r->val_len;
450 }
451 else
452 {
453 nCompare = memcmp(r->val, l->val, min(r->val_len, l->val_len));
454 if (nCompare == 0)
455 nCompare = r->val_len - l->val_len;
456 }
457
458 return nCompare;
459 }
460 }
461 }
462
463 /* Sort by name */
464 return (pSortInfo->bSortAscending ? StrCmpLogicalW(l->name, r->name) : StrCmpLogicalW(r->name, l->name));
465}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
struct tagSORT_INFO * PSORT_INFO
r l[0]
Definition: byte_order.h:168
INT WINAPI StrCmpLogicalW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:2304
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
unsigned long long DWORDLONG
Definition: intsafe.h:93
#define min(a, b)
Definition: monoChain.cc:55
#define REG_QWORD
Definition: sdbapi.c:597
BOOL bSortAscending
Definition: listview.c:29
INT iSortingColumn
Definition: listview.c:28
int32_t INT
Definition: typedefs.h:58

Referenced by ListView_Sort().

◆ CreateListColumns()

static BOOL CreateListColumns ( HWND  hWndListView,
INT  cxTotal 
)
static

Definition at line 246 of file listview.c.

247{
248 WCHAR szText[50];
249 int index;
250 LVCOLUMN lvC;
251
252 /* Create columns. */
253 lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
254 lvC.pszText = szText;
255
256 /* Load the column labels from the resource file. */
257 for (index = 0; index < MAX_LIST_COLUMNS; index++)
258 {
259 lvC.iSubItem = index;
260 lvC.cx = (cxTotal * default_column_widths[index]) / 100;
261 lvC.fmt = column_alignment[index];
263 if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) return FALSE;
264 }
265 return TRUE;
266}
#define MAX_LIST_COLUMNS
Definition: listview.c:38
static const int column_alignment[MAX_LIST_COLUMNS]
Definition: listview.c:40
static const int default_column_widths[MAX_LIST_COLUMNS]
Definition: listview.c:39
#define IDS_LIST_COLUMN_FIRST
Definition: resource.h:16
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2641
#define LVCF_WIDTH
Definition: commctrl.h:2592
#define LVCF_FMT
Definition: commctrl.h:2591
#define LVCF_SUBITEM
Definition: commctrl.h:2594
#define LVCF_TEXT
Definition: commctrl.h:2593
#define LVCOLUMN
Definition: commctrl.h:2586

Referenced by CreateListView().

◆ CreateListView()

HWND CreateListView ( HWND  hwndParent,
HMENU  id,
INT  cx 
)

Definition at line 618 of file listview.c.

619{
620 RECT rcClient;
621 HWND hwndLV;
622
623 /* Get the dimensions of the parent window's client area, and create the list view control. */
624 GetClientRect(hwndParent, &rcClient);
625 hwndLV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEW, L"List View",
627 0, 0, rcClient.right, rcClient.bottom,
628 hwndParent, id, hInst, NULL);
629 if (!hwndLV) return NULL;
630
631 /* Initialize the image list, and add items to the control. */
632 if (!CreateListColumns(hwndLV, cx)) goto fail;
633 if (!InitListViewImageLists(hwndLV)) goto fail;
634
635 return hwndLV;
636fail:
637 DestroyWindow(hwndLV);
638 return NULL;
639}
static BOOL CreateListColumns(HWND hWndListView, INT cxTotal)
Definition: listview.c:246
static BOOL InitListViewImageLists(HWND hwndLV)
Definition: listview.c:268
static HWND hwndParent
Definition: cryptui.c:300
#define WS_CHILD
Definition: pedump.c:617
#define WS_TABSTOP
Definition: pedump.c:634
#define WS_VISIBLE
Definition: pedump.c:620
#define LVS_SHOWSELALWAYS
Definition: commctrl.h:2272
#define LVS_REPORT
Definition: commctrl.h:2267
_Out_opt_ int * cx
Definition: commctrl.h:585
#define WC_LISTVIEW
Definition: commctrl.h:2264
#define LVS_EDITLABELS
Definition: commctrl.h:2278
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
BOOL WINAPI DestroyWindow(_In_ HWND)

◆ DestroyListView()

void DestroyListView ( HWND  hwndLV)

Definition at line 641 of file listview.c.

642{
643 INT count, i;
645
647 for (i = 0; i < count; i++)
648 {
649 item.mask = LVIF_PARAM;
650 item.iItem = i;
651 (void)ListView_GetItem(hwndLV, &item);
652 free(((LINE_INFO*)item.lParam)->name);
653 HeapFree(GetProcessHeap(), 0, (void*)item.lParam);
654 }
655}
#define free
Definition: debug_ros.c:5
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2312
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2399

Referenced by ChildWndProc(), and RefreshListView().

◆ GetValueName()

WCHAR * GetValueName ( HWND  hwndLV,
int  iStartAt 
)

Definition at line 42 of file listview.c.

43{
44 int item;
45 LVITEMW LVItem;
46 PLINE_INFO lineinfo;
47
48 /*
49 if a new item is inserted, then no allocation,
50 otherwise the heap block will be lost!
51 */
52 item = ListView_GetNextItem(hwndLV, iStartAt, LVNI_SELECTED);
53 if (item == -1) return NULL;
54
55 /*
56 Should be always TRUE anyways
57 */
58 LVItem.iItem = item;
59 LVItem.iSubItem = 0;
60 LVItem.mask = LVIF_PARAM;
61 if (ListView_GetItem(hwndLV, &LVItem) == FALSE)
62 return NULL;
63
64 lineinfo = (PLINE_INFO)LVItem.lParam;
65 if (lineinfo == NULL)
66 return NULL;
67
68 return lineinfo->name;
69}
if(dx< 0)
Definition: linetemp.h:194
#define LVNI_SELECTED
Definition: commctrl.h:2429
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2439
int iSubItem
Definition: commctrl.h:2367
UINT mask
Definition: commctrl.h:2365
LPARAM lParam
Definition: commctrl.h:2373

Referenced by _CmdWndProc(), and FindNext().

◆ InitListViewImageLists()

static BOOL InitListViewImageLists ( HWND  hwndLV)
static

Definition at line 268 of file listview.c.

269{
270 HIMAGELIST himl; /* handle to image list */
271 HICON hico; /* handle to icon */
272
273 /* Create the image list. */
276 {
277 return FALSE;
278 }
279
282
285
286 /* Fail if not all of the images were added. */
288 {
289 return FALSE;
290 }
291
292 /* Associate the image list with the tree view control. */
294
295 return TRUE;
296}
#define LISTVIEW_NUM_ICONS
Definition: listview.c:12
#define CX_ICON
Definition: listview.c:10
#define CY_ICON
Definition: listview.c:11
#define IDI_STRING
Definition: resource.h:30
#define IDI_BIN
Definition: resource.h:31
HICON hico
HIMAGELIST himl
INT WINAPI ImageList_GetImageCount(HIMAGELIST himl)
Definition: imagelist.c:2063
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
static HICON
Definition: imagelist.c:80
#define LVSIL_SMALL
Definition: commctrl.h:2304
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2309
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define ILC_MASK
Definition: commctrl.h:351
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2127

Referenced by CreateListView().

◆ IsDefaultValue()

BOOL IsDefaultValue ( HWND  hwndLV,
int  i 
)

Definition at line 95 of file listview.c.

96{
97 PLINE_INFO lineinfo;
99
100 Item.mask = LVIF_PARAM;
101 Item.iItem = i;
102 if(ListView_GetItem(hwndLV, &Item))
103 {
104 lineinfo = (PLINE_INFO)Item.lParam;
105 return lineinfo && (!lineinfo->name || !wcscmp(lineinfo->name, L""));
106 }
107 return FALSE;
108}
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_In_ WDFCOLLECTION _In_ WDFOBJECT Item

Referenced by ChildWndProc().

◆ ListView_Sort()

static BOOL ListView_Sort ( HWND  hListView,
int  iSortingColumn,
int  iSortedColumn 
)
static

Definition at line 467 of file listview.c.

468{
469 if (!(GetWindowLongPtr(hListView, GWL_STYLE) & LVS_NOSORTHEADER) &&
470 (iSortingColumn >= 0) )
471 {
473 SORT_INFO SortInfo;
474
475 HWND hHeader = ListView_GetHeader(hListView);
476 HDITEM hColumn = {0};
477
478 /* If we are sorting according to another column, uninitialize the old one */
479 if ( (iSortedColumn >= 0) && (iSortingColumn != iSortedColumn) )
480 {
481 hColumn.mask = HDI_FORMAT;
482 Header_GetItem(hHeader, iSortedColumn, &hColumn);
483 hColumn.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN);
484 Header_SetItem(hHeader, iSortedColumn, &hColumn);
485 }
486
487 /* Get the sorting state of the new column */
488 hColumn.mask = HDI_FORMAT;
489 Header_GetItem(hHeader, iSortingColumn, &hColumn);
490
491 /*
492 * Check whether we are sorting the list because the user clicked
493 * on a column, or because we are refreshing the list:
494 *
495 * iSortedColumn >= 0 - User clicked on a column; holds the
496 * old sorting column index.
497 * iSortedColumn < 0 - List being refreshed.
498 */
499 if (iSortedColumn >= 0)
500 {
501 /* Invert the sorting direction */
502 bSortAscending = ((hColumn.fmt & HDF_SORTUP) == 0);
503 }
504 else
505 {
506 /*
507 * If the sorting state of the column is uninitialized,
508 * initialize it by default to ascending sorting.
509 */
510 if ((hColumn.fmt & (HDF_SORTUP | HDF_SORTDOWN)) == 0)
511 hColumn.fmt |= HDF_SORTUP;
512
513 /* Keep the same sorting direction */
514 bSortAscending = ((hColumn.fmt & HDF_SORTUP) != 0);
515 }
516
517 /* Set the new column sorting state */
518 hColumn.fmt &= ~(bSortAscending ? HDF_SORTDOWN : HDF_SORTUP );
519 hColumn.fmt |= (bSortAscending ? HDF_SORTUP : HDF_SORTDOWN);
520 Header_SetItem(hHeader, iSortingColumn, &hColumn);
521
522 /* Sort the list */
523 SortInfo.iSortingColumn = iSortingColumn;
525 return ListView_SortItems(hListView, CompareFunc, (LPARAM)&SortInfo);
526 }
527 else
528 return TRUE;
529}
static BOOL bSortAscending
Definition: applpage.c:27
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: listview.c:368
unsigned int BOOL
Definition: ntddk_ex.h:94
#define Header_GetItem(hwndHD, i, phdi)
Definition: commctrl.h:751
#define Header_SetItem(hwndHD, i, phdi)
Definition: commctrl.h:758
#define ListView_GetHeader(hwnd)
Definition: commctrl.h:2656
#define HDF_SORTUP
Definition: commctrl.h:724
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2708
#define HDI_FORMAT
Definition: commctrl.h:705
#define LVS_NOSORTHEADER
Definition: commctrl.h:2290
#define HDITEM
Definition: commctrl.h:697
#define HDF_SORTDOWN
Definition: commctrl.h:725
static int iSortedColumn
Definition: srvpage.cpp:27
#define GetWindowLongPtr
Definition: treelist.c:73
#define GWL_STYLE
Definition: winuser.h:855

◆ ListWndNotifyProc()

BOOL ListWndNotifyProc ( HWND  hWnd,
WPARAM  wParam,
LPARAM  lParam,
BOOL Result 
)

Definition at line 531 of file listview.c.

532{
534 int iSortingColumn;
536 *Result = TRUE;
537 switch (((LPNMHDR)lParam)->code)
538 {
539 case LVN_GETDISPINFO:
541 return TRUE;
542 case LVN_COLUMNCLICK:
543 iSortingColumn = ((LPNMLISTVIEW)lParam)->iSubItem;
544 (void)ListView_Sort(hWnd, iSortingColumn, g_iSortedColumn);
545 g_iSortedColumn = iSortingColumn;
546 return TRUE;
547 case NM_DBLCLK:
548 case NM_RETURN:
549 {
551 }
552 return TRUE;
553 case NM_SETFOCUS:
555 break;
558 if(Info)
559 {
560 PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
561 if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
562 {
563 *Result = TRUE;
564 }
565 else
566 {
567 *Result = FALSE;
568 }
569 }
570 else
571 *Result = TRUE;
572 return TRUE;
573 case LVN_ENDLABELEDIT:
575 if(Info && Info->item.pszText)
576 {
577 PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
578 if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
579 {
580 *Result = FALSE;
581 }
582 else
583 {
584 if(wcslen(Info->item.pszText) == 0)
585 {
586 WCHAR msg[128], caption[128];
587
590 MessageBoxW(0, msg, caption, 0);
591 *Result = TRUE;
592 }
593 else
594 {
595 HKEY hKeyRoot;
596 LPCWSTR keyPath;
597 LONG lResult;
598
599 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
600 lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name);
601 lineinfo->name = realloc(lineinfo->name, (wcslen(Info->item.pszText)+1)*sizeof(WCHAR));
602 if (lineinfo->name != NULL)
603 wcscpy(lineinfo->name, Info->item.pszText);
604
605 *Result = TRUE;
606 return (lResult == ERROR_SUCCESS);
607 }
608 }
609 }
610 else
611 *Result = TRUE;
612
613 return TRUE;
614 }
615 return FALSE;
616}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
ChildWnd * g_pChildWnd
Definition: childwnd.c:13
LONG RenameValue(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpDestValue, LPCWSTR lpSrcValue)
Definition: edit.c:2006
static void OnGetDispInfo(NMLVDISPINFO *plvdi)
Definition: listview.c:300
static INT g_iSortedColumn
Definition: listview.c:36
HWND hFrameWnd
Definition: main.c:22
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:73
#define IDS_ERR_RENVAL_CAPTION
Definition: resource.h:91
#define ID_EDIT_MODIFY
Definition: resource.h:48
#define IDS_ERR_RENVAL_TOEMPTY
Definition: resource.h:92
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define realloc
Definition: debug_ros.c:6
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ListView_Sort(hListView, iSortingColumn)
Definition: listview.h:32
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
long LONG
Definition: pedump.c:60
#define LVN_COLUMNCLICK
Definition: commctrl.h:3144
#define NM_DBLCLK
Definition: commctrl.h:131
#define LVN_GETDISPINFO
Definition: commctrl.h:3165
#define LVN_ENDLABELEDIT
Definition: commctrl.h:3164
#define NMLVDISPINFO
Definition: commctrl.h:3187
#define LVN_BEGINLABELEDIT
Definition: commctrl.h:3163
#define NM_RETURN
Definition: commctrl.h:132
struct tagNMLISTVIEW * LPNMLISTVIEW
#define NM_SETFOCUS
Definition: commctrl.h:135
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
int nFocusPanel
Definition: main.h:55
HWND hTreeWnd
Definition: main.h:50
Definition: inflate.c:139
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
#define MAKEWPARAM(l, h)
Definition: winuser.h:4012
#define WM_COMMAND
Definition: winuser.h:1743
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ChildWndProc().

◆ OnGetDispInfo()

static void OnGetDispInfo ( NMLVDISPINFO plvdi)
static

Definition at line 300 of file listview.c.

301{
302 static WCHAR buffer[200];
303
304 plvdi->item.pszText = NULL;
305 plvdi->item.cchTextMax = 0;
306
307 switch (plvdi->item.iSubItem)
308 {
309 case 0:
311 plvdi->item.pszText = buffer;
312 break;
313 case 1:
314 switch (((LINE_INFO*)plvdi->item.lParam)->dwValType)
315 {
316 case REG_NONE:
317 plvdi->item.pszText = L"REG_NONE";
318 break;
319 case REG_SZ:
320 plvdi->item.pszText = L"REG_SZ";
321 break;
322 case REG_EXPAND_SZ:
323 plvdi->item.pszText = L"REG_EXPAND_SZ";
324 break;
325 case REG_BINARY:
326 plvdi->item.pszText = L"REG_BINARY";
327 break;
328 case REG_DWORD: /* REG_DWORD_LITTLE_ENDIAN */
329 plvdi->item.pszText = L"REG_DWORD";
330 break;
332 plvdi->item.pszText = L"REG_DWORD_BIG_ENDIAN";
333 break;
334 case REG_LINK:
335 plvdi->item.pszText = L"REG_LINK";
336 break;
337 case REG_MULTI_SZ:
338 plvdi->item.pszText = L"REG_MULTI_SZ";
339 break;
341 plvdi->item.pszText = L"REG_RESOURCE_LIST";
342 break;
344 plvdi->item.pszText = L"REG_FULL_RESOURCE_DESCRIPTOR";
345 break;
347 plvdi->item.pszText = L"REG_RESOURCE_REQUIREMENTS_LIST";
348 break;
349 case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
350 plvdi->item.pszText = L"REG_QWORD";
351 break;
352 default:
353 {
354 WCHAR buf2[200];
356 wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
357 plvdi->item.pszText = buffer;
358 break;
359 }
360 }
361 break;
362 case 3:
363 plvdi->item.pszText = L"";
364 break;
365 }
366}
#define IDS_DEFAULT_VALUE_NAME
Definition: resource.h:79
#define IDS_UNKNOWN_TYPE
Definition: resource.h:81
#define REG_BINARY
Definition: nt_native.h:1496
#define REG_DWORD_BIG_ENDIAN
Definition: nt_native.h:1499
#define REG_RESOURCE_LIST
Definition: nt_native.h:1502
#define REG_RESOURCE_REQUIREMENTS_LIST
Definition: nt_native.h:1504
#define REG_LINK
Definition: nt_native.h:1500
#define REG_NONE
Definition: nt_native.h:1492
#define REG_FULL_RESOURCE_DESCRIPTOR
Definition: nt_native.h:1503

Referenced by ListWndNotifyProc().

◆ RefreshListView()

BOOL RefreshListView ( HWND  hwndLV,
HKEY  hKey,
LPCWSTR  keyPath,
BOOL  bSelectNone 
)

Definition at line 657 of file listview.c.

658{
659 DWORD max_sub_key_len;
660 DWORD max_val_name_len;
661 DWORD max_val_size;
662 DWORD val_count;
663 HKEY hNewKey;
664 LONG errCode;
665 INT i, c;
666 BOOL AddedDefault = FALSE;
667
668 if (!hwndLV) return FALSE;
669
670 (void)ListView_EditLabel(hwndLV, -1);
671
672 SendMessageW(hwndLV, WM_SETREDRAW, FALSE, 0);
673 DestroyListView(hwndLV);
674
676
677 if(!hKey) return FALSE;
678
679 errCode = RegOpenKeyExW(hKey, keyPath, 0, KEY_READ, &hNewKey);
680 if (errCode != ERROR_SUCCESS) return FALSE;
681
682 /* get size information and resize the buffers if necessary */
683 errCode = RegQueryInfoKeyW(hNewKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL,
684 &val_count, &max_val_name_len, &max_val_size, NULL, NULL);
685
686 if (errCode == ERROR_SUCCESS)
687 {
688 WCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(WCHAR));
689 DWORD dwValNameLen = max_val_name_len;
690 BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, max_val_size + sizeof(WCHAR));
691 DWORD dwValSize = max_val_size;
692 DWORD dwIndex = 0L;
693 DWORD dwValType;
694 /* if (RegQueryValueExW(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
695 /* AddEntryToList(hwndLV, L"(Default)", dwValType, ValBuf, dwValSize); */
696 /* } */
697 /* dwValSize = max_val_size; */
698 while (RegEnumValueW(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS)
699 {
700 /* Add a terminating 0 character. Usually this is only necessary for strings. */
701 ValBuf[dwValSize] = ValBuf[dwValSize + 1] = 0;
702
703 AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize, -1, TRUE);
704 dwValNameLen = max_val_name_len;
705 dwValSize = max_val_size;
706 dwValType = 0L;
707 ++dwIndex;
708 if(!wcscmp(ValName, L""))
709 {
710 AddedDefault = TRUE;
711 }
712 }
713 HeapFree(GetProcessHeap(), 0, ValBuf);
714 HeapFree(GetProcessHeap(), 0, ValName);
715 }
716 RegCloseKey(hNewKey);
717
718 if(!AddedDefault)
719 {
720 AddEntryToList(hwndLV, L"", REG_SZ, NULL, 0, 0, FALSE);
721 }
722 c = ListView_GetItemCount(hwndLV);
723 for(i = 0; i < c; i++)
724 {
726 }
727
728 if (bSelectNone)
729 iListViewSelect = -1;
733 (void)ListView_Sort(hwndLV, g_iSortedColumn, -1);
734 SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0);
735
736 return TRUE;
737}
INT iListViewSelect
Definition: listview.c:16
static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType, void *ValBuf, DWORD dwCount, int Position, BOOL ValExists)
Definition: listview.c:113
void DestroyListView(HWND hwndLV)
Definition: listview.c:641
#define RegCloseKey(hKey)
Definition: registry.h:49
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
LONG WINAPI RegQueryInfoKeyW(HKEY hKey, LPWSTR lpClass, LPDWORD lpcClass, LPDWORD lpReserved, LPDWORD lpcSubKeys, LPDWORD lpcMaxSubKeyLen, LPDWORD lpcMaxClassLen, LPDWORD lpcValues, LPDWORD lpcMaxValueNameLen, LPDWORD lpcMaxValueLen, LPDWORD lpcbSecurityDescriptor, PFILETIME lpftLastWriteTime)
Definition: reg.c:3662
FxAutoRegKey hKey
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80
#define KEY_READ
Definition: nt_native.h:1023
#define ListView_SetItemState(hwndLV, i, data, mask)
Definition: commctrl.h:2678
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2545
#define LVIS_SELECTED
Definition: commctrl.h:2324
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2419
#define LVIS_FOCUSED
Definition: commctrl.h:2323
#define WM_SETREDRAW
Definition: winuser.h:1619
unsigned char BYTE
Definition: xxhash.c:193

Referenced by _CmdWndProc(), CreateNewValue(), ImportRegistryFile(), LoadHive(), UnloadHive(), and UpdateAddress().

◆ SetValueName()

VOID SetValueName ( HWND  hwndLV,
LPCWSTR  pszValueName 
)

Definition at line 71 of file listview.c.

72{
73 INT i, c;
74 LVFINDINFOW fi;
75
76 c = ListView_GetItemCount(hwndLV);
77 for(i = 0; i < c; i++)
78 {
80 }
81 if (pszValueName == NULL || pszValueName[0] == 0)
82 i = 0;
83 else
84 {
85 fi.flags = LVFI_STRING;
86 fi.psz = pszValueName;
87 i = ListView_FindItem(hwndLV, -1, &fi);
88 }
93}
#define LVFI_STRING
Definition: commctrl.h:2442
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2475
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2524
LPCWSTR psz
Definition: commctrl.h:2462

Referenced by FindNext().

Variable Documentation

◆ column_alignment

const int column_alignment[MAX_LIST_COLUMNS] = { LVCFMT_LEFT, LVCFMT_LEFT, LVCFMT_LEFT }
static

Definition at line 40 of file listview.c.

Referenced by CreateListColumns().

◆ default_column_widths

const int default_column_widths[MAX_LIST_COLUMNS] = { 35, 25, 40 }
static

Definition at line 39 of file listview.c.

Referenced by CreateListColumns().

◆ g_iSortedColumn

INT g_iSortedColumn
static

Definition at line 36 of file listview.c.

Referenced by ListWndNotifyProc(), and RefreshListView().

◆ iListViewSelect

INT iListViewSelect = -1

Definition at line 16 of file listview.c.

Referenced by RefreshListView(), and SetValueName().

◆ Image_Bin

int Image_Bin

Definition at line 15 of file listview.c.

Referenced by AddEntryToList(), and InitListViewImageLists().

◆ Image_String

int Image_String

Definition at line 14 of file listview.c.

Referenced by AddEntryToList(), and InitListViewImageLists().