ReactOS 0.4.15-dev-8434-g155a7c7
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 = 0
 
int Image_Bin = 0
 
INT iListViewSelect = -1
 
static INT g_iSortedColumn = 0
 
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 23 of file listview.c.

◆ CY_ICON

#define CY_ICON   16

Definition at line 24 of file listview.c.

◆ LISTVIEW_NUM_ICONS

#define LISTVIEW_NUM_ICONS   2

Definition at line 25 of file listview.c.

◆ MAX_LIST_COLUMNS

#define MAX_LIST_COLUMNS   (IDS_LIST_COLUMN_LAST - IDS_LIST_COLUMN_FIRST + 1)

Definition at line 51 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 126 of file listview.c.

127{
128 PLINE_INFO linfo;
130 int index;
131
132 linfo = (PLINE_INFO)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(LINE_INFO) + dwCount);
133 linfo->dwValType = dwValType;
134 linfo->val_len = dwCount;
135 if (dwCount > 0)
136 {
137 memcpy(&linfo[1], ValBuf, dwCount);
138 linfo->val = &linfo[1];
139 }
140 linfo->name = _wcsdup(Name);
141
143 item.iItem = (Position == -1 ? 0: Position);
144 item.iSubItem = 0;
145 item.state = 0;
146 item.stateMask = 0;
147 item.pszText = Name;
148 item.cchTextMax = (int)wcslen(item.pszText);
149 if (item.cchTextMax == 0)
150 item.pszText = LPSTR_TEXTCALLBACK;
151 item.iImage = 0;
152 item.lParam = (LPARAM)linfo;
153 switch(dwValType)
154 {
155 case REG_SZ:
156 case REG_EXPAND_SZ:
157 case REG_MULTI_SZ:
158 item.iImage = Image_String;
159 break;
160 default:
161 item.iImage = Image_Bin;
162 break;
163 }
164
165 /* item.lParam = (LPARAM)ValBuf; */
166#if (_WIN32_IE >= 0x0300)
167 item.iIndent = 0;
168#endif
169
170 index = ListView_InsertItem(hwndLV, &item);
171 if (index != -1)
172 {
173 switch (dwValType)
174 {
175 case REG_SZ:
176 case REG_EXPAND_SZ:
177 if(dwCount > 0)
178 {
179 ListView_SetItemText(hwndLV, index, 2, ValBuf);
180 }
181 else if(!ValExists)
182 {
183 WCHAR buffer[255];
184 /* load (value not set) string */
186 ListView_SetItemText(hwndLV, index, 2, buffer);
187 }
188 break;
189 case REG_MULTI_SZ:
190 {
191 LPWSTR src, str;
192 if(dwCount >= 2)
193 {
194 src = (LPWSTR)ValBuf;
195 str = HeapAlloc(GetProcessHeap(), 0, dwCount + sizeof(WCHAR));
196 if(str != NULL)
197 {
198 *str = L'\0';
199 /* concatenate all srings */
200 while(*src != L'\0')
201 {
202 wcscat(str, src);
203 wcscat(str, L" ");
204 src += wcslen(src) + 1;
205 }
206 ListView_SetItemText(hwndLV, index, 2, str);
208 }
209 else
210 ListView_SetItemText(hwndLV, index, 2, L"");
211 }
212 else
213 ListView_SetItemText(hwndLV, index, 2, L"");
214 }
215 break;
216 case REG_DWORD:
217 {
218 WCHAR buf[200];
219 if(dwCount == sizeof(DWORD))
220 {
221 wsprintf(buf, L"0x%08x (%u)", *(DWORD*)ValBuf, *(DWORD*)ValBuf);
222 }
223 else
224 {
226 }
227 ListView_SetItemText(hwndLV, index, 2, buf);
228 }
229 /* lpsRes = convertHexToDWORDStr(lpbData, dwLen); */
230 break;
231 default: /* REG_BINARY, REG_NONE etc. */
232 {
233 unsigned int i;
234 LPBYTE pData = (LPBYTE)ValBuf;
235 LPWSTR strBinary;
236 if(dwCount > 0)
237 {
238 strBinary = HeapAlloc(GetProcessHeap(), 0, (dwCount * sizeof(WCHAR) * 3) + sizeof(WCHAR));
239 for (i = 0; i < dwCount; i++)
240 {
241 wsprintf( strBinary + i*3, L"%02X ", pData[i] );
242 }
243 strBinary[dwCount * 3] = 0;
244 ListView_SetItemText(hwndLV, index, 2, strBinary);
245 HeapFree(GetProcessHeap(), 0, strBinary);
246 }
247 else
248 {
249 WCHAR szText[128];
250 LoadStringW(hInst, IDS_BINARY_EMPTY, szText, ARRAY_SIZE(szText));
251 ListView_SetItemText(hwndLV, index, 2, szText);
252 }
253 }
254 break;
255 }
256 }
257}
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:27
struct tagLINE_INFO * PLINE_INFO
int Image_Bin
Definition: listview.c:28
#define ARRAY_SIZE(A)
Definition: main.h:33
#define IDS_BINARY_EMPTY
Definition: resource.h:125
#define IDS_VALUE_NOT_SET
Definition: resource.h:127
#define IDS_INVALID_DWORD
Definition: resource.h:132
#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:2408
#define LPSTR_TEXTCALLBACK
Definition: commctrl.h:2383
#define LVIF_PARAM
Definition: commctrl.h:2311
#define ListView_SetItemText(hwndLV, i, iSubItem_, pszText_)
Definition: commctrl.h:2691
#define LVIF_TEXT
Definition: commctrl.h:2309
#define LVIF_IMAGE
Definition: commctrl.h:2310
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:33
void * val
Definition: listview.c:35
LPWSTR name
Definition: listview.c:34
size_t val_len
Definition: listview.c:36
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:5874
__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 381 of file listview.c.

382{
383 PSORT_INFO pSortInfo = (PSORT_INFO)lParamSort;
384 LINE_INFO *l, *r;
385 DWORD dw1, dw2;
386 DWORDLONG qw1, qw2;
387
388 l = (LINE_INFO*)lParam1;
389 r = (LINE_INFO*)lParam2;
390
391 if (pSortInfo->iSortingColumn == 1 && l->dwValType != r->dwValType)
392 {
393 /* Sort by type */
394 if (pSortInfo->bSortAscending)
395 return ((int)l->dwValType - (int)r->dwValType);
396 else
397 return ((int)r->dwValType - (int)l->dwValType);
398 }
399 if (pSortInfo->iSortingColumn == 2)
400 {
401 /* Sort by value */
402 if (l->dwValType != r->dwValType)
403 {
404 if (pSortInfo->bSortAscending)
405 return ((int)l->dwValType - (int)r->dwValType);
406 else
407 return ((int)r->dwValType - (int)l->dwValType);
408 }
409
410 if (l->val == NULL && r->val == NULL)
411 return 0;
412
413 if (pSortInfo->bSortAscending)
414 {
415 if (l->val == NULL)
416 return -1;
417 if (r->val == NULL)
418 return 1;
419 }
420 else
421 {
422 if (l->val == NULL)
423 return 1;
424 if (r->val == NULL)
425 return -1;
426 }
427
428 switch(l->dwValType)
429 {
430 case REG_DWORD:
431 {
432 dw1 = *(DWORD*)l->val;
433 dw2 = *(DWORD*)r->val;
434 if (pSortInfo->bSortAscending)
435 // return (dw1 > dw2 ? 1 : -1);
436 return ((int)dw1 - (int)dw2);
437 else
438 // return (dw1 > dw2 ? -1 : 1);
439 return ((int)dw2 - (int)dw1);
440 }
441
442 case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
443 {
444 qw1 = *(DWORDLONG*)l->val;
445 qw2 = *(DWORDLONG*)r->val;
446 if (pSortInfo->bSortAscending)
447 // return (qw1 > qw2 ? 1 : -1);
448 return ((int)qw1 - (int)qw2);
449 else
450 // return (qw1 > qw2 ? -1 : 1);
451 return ((int)qw2 - (int)qw1);
452 }
453
454 default:
455 {
456 INT nCompare = 0;
457
458 if (pSortInfo->bSortAscending)
459 {
460 nCompare = memcmp(l->val, r->val, min(l->val_len, r->val_len));
461 if (nCompare == 0)
462 nCompare = l->val_len - r->val_len;
463 }
464 else
465 {
466 nCompare = memcmp(r->val, l->val, min(r->val_len, l->val_len));
467 if (nCompare == 0)
468 nCompare = r->val_len - l->val_len;
469 }
470
471 return nCompare;
472 }
473 }
474 }
475
476 /* Sort by name */
477 return (pSortInfo->bSortAscending ? StrCmpLogicalW(l->name, r->name) : StrCmpLogicalW(r->name, l->name));
478}
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:42
INT iSortingColumn
Definition: listview.c:41
int32_t INT
Definition: typedefs.h:58

Referenced by ListView_Sort().

◆ CreateListColumns()

static BOOL CreateListColumns ( HWND  hWndListView,
INT  cxTotal 
)
static

Definition at line 259 of file listview.c.

260{
261 WCHAR szText[50];
262 int index;
263 LVCOLUMN lvC;
264
265 /* Create columns. */
266 lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
267 lvC.pszText = szText;
268
269 /* Load the column labels from the resource file. */
270 for (index = 0; index < MAX_LIST_COLUMNS; index++)
271 {
272 lvC.iSubItem = index;
273 lvC.cx = (cxTotal * default_column_widths[index]) / 100;
274 lvC.fmt = column_alignment[index];
276 if (ListView_InsertColumn(hWndListView, index, &lvC) == -1) return FALSE;
277 }
278 return TRUE;
279}
#define MAX_LIST_COLUMNS
Definition: listview.c:51
static const int column_alignment[MAX_LIST_COLUMNS]
Definition: listview.c:53
static const int default_column_widths[MAX_LIST_COLUMNS]
Definition: listview.c:52
#define IDS_LIST_COLUMN_FIRST
Definition: resource.h:29
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2636
#define LVCF_WIDTH
Definition: commctrl.h:2587
#define LVCF_FMT
Definition: commctrl.h:2586
#define LVCF_SUBITEM
Definition: commctrl.h:2589
#define LVCF_TEXT
Definition: commctrl.h:2588
#define LVCOLUMN
Definition: commctrl.h:2581

Referenced by CreateListView().

◆ CreateListView()

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

Definition at line 631 of file listview.c.

632{
633 RECT rcClient;
634 HWND hwndLV;
635
636 /* Get the dimensions of the parent window's client area, and create the list view control. */
637 GetClientRect(hwndParent, &rcClient);
638 hwndLV = CreateWindowExW(WS_EX_CLIENTEDGE, WC_LISTVIEW, L"List View",
640 0, 0, rcClient.right, rcClient.bottom,
641 hwndParent, id, hInst, NULL);
642 if (!hwndLV) return NULL;
643
644 /* Initialize the image list, and add items to the control. */
645 if (!CreateListColumns(hwndLV, cx)) goto fail;
646 if (!InitListViewImageLists(hwndLV)) goto fail;
647
648 return hwndLV;
649fail:
650 DestroyWindow(hwndLV);
651 return NULL;
652}
static BOOL CreateListColumns(HWND hWndListView, INT cxTotal)
Definition: listview.c:259
static BOOL InitListViewImageLists(HWND hwndLV)
Definition: listview.c:281
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:2267
#define LVS_REPORT
Definition: commctrl.h:2262
_Out_opt_ int * cx
Definition: commctrl.h:585
#define WC_LISTVIEW
Definition: commctrl.h:2259
#define LVS_EDITLABELS
Definition: commctrl.h:2273
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 654 of file listview.c.

655{
656 INT count, i;
658
660 for (i = 0; i < count; i++)
661 {
662 item.mask = LVIF_PARAM;
663 item.iItem = i;
664 (void)ListView_GetItem(hwndLV, &item);
665 free(((LINE_INFO*)item.lParam)->name);
666 HeapFree(GetProcessHeap(), 0, (void*)item.lParam);
667 }
668
669}
#define free
Definition: debug_ros.c:5
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2307
#define ListView_GetItem(hwnd, pitem)
Definition: commctrl.h:2394

Referenced by ChildWndProc(), and RefreshListView().

◆ GetValueName()

WCHAR * GetValueName ( HWND  hwndLV,
int  iStartAt 
)

Definition at line 55 of file listview.c.

56{
57 int item;
58 LVITEMW LVItem;
59 PLINE_INFO lineinfo;
60
61 /*
62 if a new item is inserted, then no allocation,
63 otherwise the heap block will be lost!
64 */
65 item = ListView_GetNextItem(hwndLV, iStartAt, LVNI_SELECTED);
66 if (item == -1) return NULL;
67
68 /*
69 Should be always TRUE anyways
70 */
71 LVItem.iItem = item;
72 LVItem.iSubItem = 0;
73 LVItem.mask = LVIF_PARAM;
74 if (ListView_GetItem(hwndLV, &LVItem) == FALSE)
75 return NULL;
76
77 lineinfo = (PLINE_INFO)LVItem.lParam;
78 if (lineinfo == NULL)
79 return NULL;
80
81 return lineinfo->name;
82}
if(dx< 0)
Definition: linetemp.h:194
#define LVNI_SELECTED
Definition: commctrl.h:2424
#define ListView_GetNextItem(hwnd, i, flags)
Definition: commctrl.h:2434
int iSubItem
Definition: commctrl.h:2362
UINT mask
Definition: commctrl.h:2360
LPARAM lParam
Definition: commctrl.h:2368

Referenced by _CmdWndProc(), and FindNext().

◆ InitListViewImageLists()

static BOOL InitListViewImageLists ( HWND  hwndLV)
static

Definition at line 281 of file listview.c.

282{
283 HIMAGELIST himl; /* handle to image list */
284 HICON hico; /* handle to icon */
285
286 /* Create the image list. */
289 {
290 return FALSE;
291 }
292
295
298
299 /* Fail if not all of the images were added. */
301 {
302 return FALSE;
303 }
304
305 /* Associate the image list with the tree view control. */
307
308 return TRUE;
309}
#define LISTVIEW_NUM_ICONS
Definition: listview.c:25
#define CX_ICON
Definition: listview.c:23
#define CY_ICON
Definition: listview.c:24
#define IDI_STRING
Definition: resource.h:43
#define IDI_BIN
Definition: resource.h:44
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:84
#define LVSIL_SMALL
Definition: commctrl.h:2299
#define ListView_SetImageList(hwnd, himl, iImageList)
Definition: commctrl.h:2304
#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:2119

Referenced by CreateListView().

◆ IsDefaultValue()

BOOL IsDefaultValue ( HWND  hwndLV,
int  i 
)

Definition at line 108 of file listview.c.

109{
110 PLINE_INFO lineinfo;
112
113 Item.mask = LVIF_PARAM;
114 Item.iItem = i;
115 if(ListView_GetItem(hwndLV, &Item))
116 {
117 lineinfo = (PLINE_INFO)Item.lParam;
118 return lineinfo && (!lineinfo->name || !wcscmp(lineinfo->name, L""));
119 }
120 return FALSE;
121}
_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 480 of file listview.c.

481{
482 if (!(GetWindowLongPtr(hListView, GWL_STYLE) & LVS_NOSORTHEADER) &&
483 (iSortingColumn >= 0) )
484 {
486 SORT_INFO SortInfo;
487
488 HWND hHeader = ListView_GetHeader(hListView);
489 HDITEM hColumn = {0};
490
491 /* If we are sorting according to another column, uninitialize the old one */
492 if ( (iSortedColumn >= 0) && (iSortingColumn != iSortedColumn) )
493 {
494 hColumn.mask = HDI_FORMAT;
495 Header_GetItem(hHeader, iSortedColumn, &hColumn);
496 hColumn.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN);
497 Header_SetItem(hHeader, iSortedColumn, &hColumn);
498 }
499
500 /* Get the sorting state of the new column */
501 hColumn.mask = HDI_FORMAT;
502 Header_GetItem(hHeader, iSortingColumn, &hColumn);
503
504 /*
505 * Check whether we are sorting the list because the user clicked
506 * on a column, or because we are refreshing the list:
507 *
508 * iSortedColumn >= 0 - User clicked on a column; holds the
509 * old sorting column index.
510 * iSortedColumn < 0 - List being refreshed.
511 */
512 if (iSortedColumn >= 0)
513 {
514 /* Invert the sorting direction */
515 bSortAscending = ((hColumn.fmt & HDF_SORTUP) == 0);
516 }
517 else
518 {
519 /*
520 * If the sorting state of the column is uninitialized,
521 * initialize it by default to ascending sorting.
522 */
523 if ((hColumn.fmt & (HDF_SORTUP | HDF_SORTDOWN)) == 0)
524 hColumn.fmt |= HDF_SORTUP;
525
526 /* Keep the same sorting direction */
527 bSortAscending = ((hColumn.fmt & HDF_SORTUP) != 0);
528 }
529
530 /* Set the new column sorting state */
531 hColumn.fmt &= ~(bSortAscending ? HDF_SORTDOWN : HDF_SORTUP );
532 hColumn.fmt |= (bSortAscending ? HDF_SORTUP : HDF_SORTDOWN);
533 Header_SetItem(hHeader, iSortingColumn, &hColumn);
534
535 /* Sort the list */
536 SortInfo.iSortingColumn = iSortingColumn;
538 return ListView_SortItems(hListView, CompareFunc, (LPARAM)&SortInfo);
539 }
540 else
541 return TRUE;
542}
static BOOL bSortAscending
Definition: applpage.c:27
static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
Definition: listview.c:381
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:2651
#define HDF_SORTUP
Definition: commctrl.h:724
#define ListView_SortItems(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2703
#define HDI_FORMAT
Definition: commctrl.h:705
#define LVS_NOSORTHEADER
Definition: commctrl.h:2285
#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:852

◆ ListWndNotifyProc()

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

Definition at line 544 of file listview.c.

545{
547 int iSortingColumn;
549 *Result = TRUE;
550 switch (((LPNMHDR)lParam)->code)
551 {
552 case LVN_GETDISPINFO:
554 return TRUE;
555 case LVN_COLUMNCLICK:
556 iSortingColumn = ((LPNMLISTVIEW)lParam)->iSubItem;
557 (void)ListView_Sort(hWnd, iSortingColumn, g_iSortedColumn);
558 g_iSortedColumn = iSortingColumn;
559 return TRUE;
560 case NM_DBLCLK:
561 case NM_RETURN:
562 {
564 }
565 return TRUE;
566 case NM_SETFOCUS:
568 break;
571 if(Info)
572 {
573 PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
574 if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
575 {
576 *Result = TRUE;
577 }
578 else
579 {
580 *Result = FALSE;
581 }
582 }
583 else
584 *Result = TRUE;
585 return TRUE;
586 case LVN_ENDLABELEDIT:
588 if(Info && Info->item.pszText)
589 {
590 PLINE_INFO lineinfo = (PLINE_INFO)Info->item.lParam;
591 if(!lineinfo->name || !wcscmp(lineinfo->name, L""))
592 {
593 *Result = FALSE;
594 }
595 else
596 {
597 if(wcslen(Info->item.pszText) == 0)
598 {
599 WCHAR msg[128], caption[128];
600
603 MessageBoxW(0, msg, caption, 0);
604 *Result = TRUE;
605 }
606 else
607 {
608 HKEY hKeyRoot;
609 LPCWSTR keyPath;
610 LONG lResult;
611
612 keyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hKeyRoot);
613 lResult = RenameValue(hKeyRoot, keyPath, Info->item.pszText, lineinfo->name);
614 lineinfo->name = realloc(lineinfo->name, (wcslen(Info->item.pszText)+1)*sizeof(WCHAR));
615 if (lineinfo->name != NULL)
616 wcscpy(lineinfo->name, Info->item.pszText);
617
618 *Result = TRUE;
619 return (lResult == ERROR_SUCCESS);
620 }
621 }
622 }
623 else
624 *Result = TRUE;
625
626 return TRUE;
627 }
628 return FALSE;
629}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
ChildWnd * g_pChildWnd
Definition: childwnd.c:26
LONG RenameValue(HKEY hKey, LPCWSTR lpSubKey, LPCWSTR lpDestValue, LPCWSTR lpSrcValue)
Definition: edit.c:2028
static void OnGetDispInfo(NMLVDISPINFO *plvdi)
Definition: listview.c:313
static INT g_iSortedColumn
Definition: listview.c:49
HWND hFrameWnd
Definition: main.c:35
LPCWSTR GetItemPath(HWND hwndTV, HTREEITEM hItem, HKEY *phRootKey)
Definition: treeview.c:88
#define IDS_ERR_RENVAL_CAPTION
Definition: resource.h:138
#define ID_EDIT_MODIFY
Definition: resource.h:62
#define IDS_ERR_RENVAL_TOEMPTY
Definition: resource.h:139
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:3139
#define NM_DBLCLK
Definition: commctrl.h:131
#define LVN_GETDISPINFO
Definition: commctrl.h:3160
#define LVN_ENDLABELEDIT
Definition: commctrl.h:3159
#define NMLVDISPINFO
Definition: commctrl.h:3182
#define LVN_BEGINLABELEDIT
Definition: commctrl.h:3158
#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:68
HWND hTreeWnd
Definition: main.h:63
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:4009
#define WM_COMMAND
Definition: winuser.h:1740
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 313 of file listview.c.

314{
315 static WCHAR buffer[200];
316
317 plvdi->item.pszText = NULL;
318 plvdi->item.cchTextMax = 0;
319
320 switch (plvdi->item.iSubItem)
321 {
322 case 0:
324 plvdi->item.pszText = buffer;
325 break;
326 case 1:
327 switch (((LINE_INFO*)plvdi->item.lParam)->dwValType)
328 {
329 case REG_NONE:
330 plvdi->item.pszText = L"REG_NONE";
331 break;
332 case REG_SZ:
333 plvdi->item.pszText = L"REG_SZ";
334 break;
335 case REG_EXPAND_SZ:
336 plvdi->item.pszText = L"REG_EXPAND_SZ";
337 break;
338 case REG_BINARY:
339 plvdi->item.pszText = L"REG_BINARY";
340 break;
341 case REG_DWORD: /* REG_DWORD_LITTLE_ENDIAN */
342 plvdi->item.pszText = L"REG_DWORD";
343 break;
345 plvdi->item.pszText = L"REG_DWORD_BIG_ENDIAN";
346 break;
347 case REG_LINK:
348 plvdi->item.pszText = L"REG_LINK";
349 break;
350 case REG_MULTI_SZ:
351 plvdi->item.pszText = L"REG_MULTI_SZ";
352 break;
354 plvdi->item.pszText = L"REG_RESOURCE_LIST";
355 break;
357 plvdi->item.pszText = L"REG_FULL_RESOURCE_DESCRIPTOR";
358 break;
360 plvdi->item.pszText = L"REG_RESOURCE_REQUIREMENTS_LIST";
361 break;
362 case REG_QWORD: /* REG_QWORD_LITTLE_ENDIAN */
363 plvdi->item.pszText = L"REG_QWORD";
364 break;
365 default:
366 {
367 WCHAR buf2[200];
369 wsprintf(buffer, buf2, ((LINE_INFO*)plvdi->item.lParam)->dwValType);
370 plvdi->item.pszText = buffer;
371 break;
372 }
373 }
374 break;
375 case 3:
376 plvdi->item.pszText = L"";
377 break;
378 }
379}
#define IDS_DEFAULT_VALUE_NAME
Definition: resource.h:126
#define IDS_UNKNOWN_TYPE
Definition: resource.h:128
#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 671 of file listview.c.

672{
673 DWORD max_sub_key_len;
674 DWORD max_val_name_len;
675 DWORD max_val_size;
676 DWORD val_count;
677 HKEY hNewKey;
678 LONG errCode;
679 INT i, c;
680 BOOL AddedDefault = FALSE;
681
682 if (!hwndLV) return FALSE;
683
684 (void)ListView_EditLabel(hwndLV, -1);
685
686 SendMessageW(hwndLV, WM_SETREDRAW, FALSE, 0);
687 DestroyListView(hwndLV);
688
690
691 if(!hKey) return FALSE;
692
693 errCode = RegOpenKeyExW(hKey, keyPath, 0, KEY_READ, &hNewKey);
694 if (errCode != ERROR_SUCCESS) return FALSE;
695
696 /* get size information and resize the buffers if necessary */
697 errCode = RegQueryInfoKeyW(hNewKey, NULL, NULL, NULL, NULL, &max_sub_key_len, NULL,
698 &val_count, &max_val_name_len, &max_val_size, NULL, NULL);
699
700 if (errCode == ERROR_SUCCESS)
701 {
702 WCHAR* ValName = HeapAlloc(GetProcessHeap(), 0, ++max_val_name_len * sizeof(WCHAR));
703 DWORD dwValNameLen = max_val_name_len;
704 BYTE* ValBuf = HeapAlloc(GetProcessHeap(), 0, max_val_size + sizeof(WCHAR));
705 DWORD dwValSize = max_val_size;
706 DWORD dwIndex = 0L;
707 DWORD dwValType;
708 /* if (RegQueryValueExW(hNewKey, NULL, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS) { */
709 /* AddEntryToList(hwndLV, L"(Default)", dwValType, ValBuf, dwValSize); */
710 /* } */
711 /* dwValSize = max_val_size; */
712 while (RegEnumValueW(hNewKey, dwIndex, ValName, &dwValNameLen, NULL, &dwValType, ValBuf, &dwValSize) == ERROR_SUCCESS)
713 {
714 /* Add a terminating 0 character. Usually this is only necessary for strings. */
715 ValBuf[dwValSize] = ValBuf[dwValSize + 1] = 0;
716
717 AddEntryToList(hwndLV, ValName, dwValType, ValBuf, dwValSize, -1, TRUE);
718 dwValNameLen = max_val_name_len;
719 dwValSize = max_val_size;
720 dwValType = 0L;
721 ++dwIndex;
722 if(!wcscmp(ValName, L""))
723 {
724 AddedDefault = TRUE;
725 }
726 }
727 HeapFree(GetProcessHeap(), 0, ValBuf);
728 HeapFree(GetProcessHeap(), 0, ValName);
729 }
730 RegCloseKey(hNewKey);
731
732 if(!AddedDefault)
733 {
734 AddEntryToList(hwndLV, L"", REG_SZ, NULL, 0, 0, FALSE);
735 }
736 c = ListView_GetItemCount(hwndLV);
737 for(i = 0; i < c; i++)
738 {
740 }
741
742 if (bSelectNone)
743 iListViewSelect = -1;
747 (void)ListView_Sort(hwndLV, g_iSortedColumn, -1);
748 SendMessageW(hwndLV, WM_SETREDRAW, TRUE, 0);
749
750 return TRUE;
751}
INT iListViewSelect
Definition: listview.c:29
static void AddEntryToList(HWND hwndLV, LPWSTR Name, DWORD dwValType, void *ValBuf, DWORD dwCount, int Position, BOOL ValExists)
Definition: listview.c:126
void DestroyListView(HWND hwndLV)
Definition: listview.c:654
#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:2673
#define ListView_EditLabel(hwndLV, i)
Definition: commctrl.h:2540
#define LVIS_SELECTED
Definition: commctrl.h:2319
#define ListView_DeleteAllItems(hwnd)
Definition: commctrl.h:2414
#define LVIS_FOCUSED
Definition: commctrl.h:2318
#define WM_SETREDRAW
Definition: winuser.h:1616
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 84 of file listview.c.

85{
86 INT i, c;
87 LVFINDINFOW fi;
88
89 c = ListView_GetItemCount(hwndLV);
90 for(i = 0; i < c; i++)
91 {
93 }
94 if (pszValueName == NULL || pszValueName[0] == 0)
95 i = 0;
96 else
97 {
98 fi.flags = LVFI_STRING;
99 fi.psz = pszValueName;
100 i = ListView_FindItem(hwndLV, -1, &fi);
101 }
106}
#define LVFI_STRING
Definition: commctrl.h:2437
#define ListView_FindItem(hwnd, iStart, plvfi)
Definition: commctrl.h:2470
#define ListView_EnsureVisible(hwndLV, i, fPartialOK)
Definition: commctrl.h:2519
LPCWSTR psz
Definition: commctrl.h:2457

Referenced by FindNext().

Variable Documentation

◆ column_alignment

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

Definition at line 53 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 52 of file listview.c.

Referenced by CreateListColumns().

◆ g_iSortedColumn

INT g_iSortedColumn = 0
static

Definition at line 49 of file listview.c.

Referenced by ListWndNotifyProc(), and RefreshListView().

◆ iListViewSelect

INT iListViewSelect = -1

Definition at line 29 of file listview.c.

Referenced by RefreshListView(), and SetValueName().

◆ Image_Bin

int Image_Bin = 0

Definition at line 28 of file listview.c.

Referenced by AddEntryToList(), and InitListViewImageLists().

◆ Image_String

int Image_String = 0

Definition at line 27 of file listview.c.

Referenced by AddEntryToList(), and InitListViewImageLists().