ReactOS 0.4.16-dev-88-ga65b6ae
listview.h File Reference
#include "comctl32supp.h"
Include dependency graph for listview.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ListView_Sort(hListView, iSortingColumn)    ListView_SortEx((hListView), (iSortingColumn), -1)
 

Functions

int CALLBACK SortListView (LPARAM lItemParam1, LPARAM lItemParam2, LPARAM lPSort_S)
 
BOOL ListView_SortEx (HWND hListView, int iSortingColumn, int iSortedColumn)
 

Macro Definition Documentation

◆ ListView_Sort

#define ListView_Sort (   hListView,
  iSortingColumn 
)     ListView_SortEx((hListView), (iSortingColumn), -1)

Definition at line 32 of file listview.h.

Function Documentation

◆ ListView_SortEx()

BOOL ListView_SortEx ( HWND  hListView,
int  iSortingColumn,
int  iSortedColumn 
)

Definition at line 43 of file listview.c.

46{
47 HWND hHeader;
48 HDITEM hColumn;
49 BOOL bSortAsc;
50 Sort sort;
51
53 return TRUE;
54
55 hHeader = ListView_GetHeader(hListView);
56 SecureZeroMemory(&hColumn, sizeof(hColumn));
57
58 if ( (iSortedColumn != -1) && (iSortedColumn != iSortingColumn) )
59 {
60 hColumn.mask = HDI_FORMAT | HDI_LPARAM;
61 Header_GetItem(hHeader, iSortedColumn, &hColumn);
62 hColumn.fmt &= ~HDF_SORTUP & ~HDF_SORTDOWN;
63 hColumn.lParam = 0; // 0: deactivated, 1: false, 2: true.
64 Header_SetItem(hHeader, iSortedColumn, &hColumn);
65 }
66
67 hColumn.mask = HDI_FORMAT | HDI_LPARAM;
68 Header_GetItem(hHeader, iSortingColumn, &hColumn);
69
70 bSortAsc = !(hColumn.lParam == 2); // 0: deactivated, 1: false, 2: true.
71
72 hColumn.fmt &= (bSortAsc ? ~HDF_SORTDOWN : ~HDF_SORTUP );
73 hColumn.fmt |= (bSortAsc ? HDF_SORTUP : HDF_SORTDOWN);
74 hColumn.lParam = (LPARAM)(bSortAsc ? 2 : 1);
75 Header_SetItem(hHeader, iSortingColumn, &hColumn);
76
77 /* Sort the list */
78 sort.bSortAsc = bSortAsc;
79 sort.hList = hListView;
80 sort.nClickedColumn = iSortingColumn;
81 return ListView_SortItemsEx(hListView, SortListView, (LPARAM)&sort);
82}
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
int CALLBACK SortListView(LPARAM lItemParam1, LPARAM lItemParam2, LPARAM lPSort_S)
Definition: listview.c:22
#define TRUE
Definition: types.h:120
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 HDI_FORMAT
Definition: commctrl.h:705
#define LVS_NOSORTHEADER
Definition: commctrl.h:2290
#define HDI_LPARAM
Definition: commctrl.h:706
#define HDITEM
Definition: commctrl.h:697
#define HDF_SORTDOWN
Definition: commctrl.h:725
#define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2806
static int iSortedColumn
Definition: srvpage.cpp:27
#define GetWindowLongPtr
Definition: treelist.c:73
#define SecureZeroMemory
Definition: winbase.h:1713
LONG_PTR LPARAM
Definition: windef.h:208
#define GWL_STYLE
Definition: winuser.h:855

Referenced by ServicesPageWndProc(), and ToolsPageWndProc().

◆ SortListView()

int CALLBACK SortListView ( LPARAM  lItemParam1,
LPARAM  lItemParam2,
LPARAM  lPSort_S 
)

Definition at line 22 of file listview.c.

25{
26 PSort pSort = (PSort)lPSort_S;
27
28 int iItem1 = (int)lItemParam1;
29 int iItem2 = (int)lItemParam2;
30
31 WCHAR strItem1[MAX_VALUE_NAME];
32 WCHAR strItem2[MAX_VALUE_NAME];
33
34 ListView_GetItemText(pSort->hList, iItem1, pSort->nClickedColumn, strItem1, MAX_VALUE_NAME);
35 ListView_GetItemText(pSort->hList, iItem2, pSort->nClickedColumn, strItem2, MAX_VALUE_NAME);
36
37 // StrCmpLogicalW helps in comparing numbers intelligently, 10 is greater that 2, other
38 // wise string comparison will always return 2 is greater that 10...
39 return ( pSort->bSortAsc ? StrCmpLogicalW(strItem1, strItem2) : StrCmpLogicalW(strItem2, strItem1) );
40}
#define MAX_VALUE_NAME
Definition: control.c:28
struct __tagSort * PSort
INT WINAPI StrCmpLogicalW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:2304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2689
int nClickedColumn
Definition: listview.c:17
HWND hList
Definition: listview.c:16
BOOL bSortAsc
Definition: listview.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by ListView_SortEx().