ReactOS 0.4.15-dev-7924-g5949c20
listview.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Applications
3 * LICENSE: LGPL - See COPYING in the top level directory
4 * FILE: base/applications/msconfig_new/comctl32ex/listview.c
5 * PURPOSE: List-View helper functions.
6 * COPYRIGHT: Copyright 2011-2012 Hermes BELUSCA - MAITO <hermes.belusca@sfr.fr>
7 */
8
9#include "precomp.h"
10#include "listview.h"
11
13
14typedef struct __tagSort
15{
20
21int CALLBACK
22SortListView(LPARAM lItemParam1,
23 LPARAM lItemParam2,
24 LPARAM lPSort_S)
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}
41
42BOOL
44 int iSortingColumn,
45 int iSortedColumn)
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}
83
85
86/* EOF */
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
#define MAX_VALUE_NAME
Definition: control.c:28
struct __tagSort * PSort
BOOL ListView_SortEx(HWND hListView, int iSortingColumn, int iSortedColumn)
Definition: listview.c:43
struct __tagSort Sort
int CALLBACK SortListView(LPARAM lItemParam1, LPARAM lItemParam2, LPARAM lPSort_S)
Definition: listview.c:22
#define TRUE
Definition: types.h:120
#define CALLBACK
Definition: compat.h:35
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
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_GetItemText(hwndLV, i, iSubItem_, pszText_, cchTextMax_)
Definition: commctrl.h:2684
#define ListView_GetHeader(hwnd)
Definition: commctrl.h:2651
#define HDF_SORTUP
Definition: commctrl.h:724
#define HDI_FORMAT
Definition: commctrl.h:705
#define LVS_NOSORTHEADER
Definition: commctrl.h:2285
#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:2801
static int iSortedColumn
Definition: srvpage.cpp:27
int nClickedColumn
Definition: listview.c:17
HWND hList
Definition: listview.c:16
BOOL bSortAsc
Definition: listview.c:18
#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:852
__wchar_t WCHAR
Definition: xmlstorage.h:180