ReactOS  0.4.12-dev-18-gf469aca
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.

Referenced by ServicesPageWndProc(), and ToolsPageWndProc().

Function Documentation

◆ ListView_SortEx()

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

Definition at line 43 of file listview.c.

Referenced by ServicesPageWndProc(), and ToolsPageWndProc().

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 }
#define TRUE
Definition: types.h:120
#define SecureZeroMemory
Definition: winbase.h:1636
#define ListView_GetHeader(hwnd)
Definition: commctrl.h:2621
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
#define HDF_SORTUP
Definition: commctrl.h:709
#define HDITEM
Definition: commctrl.h:682
LONG_PTR LPARAM
Definition: windef.h:208
#define HDI_FORMAT
Definition: commctrl.h:690
#define Header_GetItem(hwndHD, i, phdi)
Definition: commctrl.h:736
static int iSortedColumn
Definition: srvpage.cpp:27
BOOL bSortAsc
Definition: listview.c:18
unsigned int BOOL
Definition: ntddk_ex.h:94
HWND hList
Definition: listview.c:16
#define HDF_SORTDOWN
Definition: commctrl.h:710
int CALLBACK SortListView(LPARAM lItemParam1, LPARAM lItemParam2, LPARAM lPSort_S)
Definition: listview.c:22
#define GWL_STYLE
Definition: winuser.h:846
HWND hListView
Definition: gui.cpp:29
int nClickedColumn
Definition: listview.c:17
#define ListView_SortItemsEx(hwndLV, _pfnCompare, _lPrm)
Definition: commctrl.h:2771
#define HDI_LPARAM
Definition: commctrl.h:691
#define LVS_NOSORTHEADER
Definition: commctrl.h:2255
#define GetWindowLongPtr
Definition: treelist.c:73
#define Header_SetItem(hwndHD, i, phdi)
Definition: commctrl.h:743
#define LPARAM
Definition: msvc.h:38

◆ SortListView()

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

Definition at line 22 of file listview.c.

Referenced by ListView_SortEx().

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 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define ListView_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2654
#define MAX_VALUE_NAME
Definition: control.c:23
BOOL bSortAsc
Definition: listview.c:18
struct __tagSort * PSort
static int
Definition: listview.c:31
HWND hList
Definition: listview.c:16
INT WINAPI StrCmpLogicalW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:2296
int nClickedColumn
Definition: listview.c:17