Repository navigation
Expand file tree
/
Copy pathListView.cpp
More file actions
158 lines (128 loc) · 3.15 KB
/
Copy pathListView.cpp
File metadata and controls
158 lines (128 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// ListView.cpp: implementation of the ListView class.
//
//////////////////////////////////////////////////////////////////////
#include "ListView.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ListView::ListView()
{
this->strControlClass = "SysListView32";
this->dwStyle = WS_CHILD | WS_VISIBLE;
this->dwExStyle = WS_EX_WINDOWEDGE;
}
ListView::~ListView()
{
}
BOOL ListView::Create(HWND parent, DWORD id, DWORD style, DWORD exStyle)
{
if (CommonControl::Create(parent, id, style, exStyle))
{
this->hHeader = ::CreateWindow( WC_HEADER,
"",
HDS_HORZ|HDS_BUTTONS,
0,
0,
100,
100,
this->hWnd,
NULL,
GetModuleHandle(NULL),
NULL);
if (this->hHeader == NULL)
{
AddError("Aanmaken van de header is niet gelukt");
return false;
}
return true;
}
return false;
}
LPLVITEM ListView::GetItem(UINT index)
{
LVITEM *lvi;
lvi = new LVITEM;
lvi->mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH | LVCF_FMT | LVIF_PARAM;
lvi->iItem = index;
lvi->iSubItem = 0;
ListView_GetItem(this->hWnd, lvi);
return lvi;
}
VOID ListView::AddColumn(LPTSTR title, UINT width, UINT index)
{
LV_COLUMN lvc;
lvc.mask = LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH | LVCF_FMT;
lvc.fmt = LVCFMT_LEFT ;
lvc.cchTextMax = 300;
lvc.cx = width;
lvc.pszText = title;
lvc.iSubItem = index;
ListView_InsertColumn(this->hWnd, index, &lvc);
}
VOID ListView::RemoveColumn(UINT index)
{
ListView_DeleteColumn(this->hWnd, index);
}
VOID ListView::ClearColumns()
{
DWORD result = 1;
while (result)
{
result = ListView_DeleteColumn(this->hWnd, 0);
}
}
VOID ListView::AddItem(LPTSTR text, UINT index, DWORD image, LPARAM data)
{
LV_ITEM lvi;
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
lvi.state = 0;
lvi.stateMask = -1;
lvi.iItem = index;
lvi.iSubItem = 0;
lvi.pszText = text;
lvi.iImage = image;
lvi.lParam = data;
ListView_InsertItem(this->hWnd, &lvi );
}
VOID ListView::AddSubitem(LPTSTR text, UINT index, UINT subindex, LPARAM data)
{
ListView_SetItemText(this->hWnd, index, subindex, text);
}
VOID ListView::RemoveItem(UINT index)
{
ListView_DeleteItem(this->hWnd, index);
}
VOID ListView::ClearItems()
{
ListView_DeleteAllItems(this->hWnd);
}
VOID ListView::GetItemText(UINT index, LPTSTR text, UINT size)
{
ListView_GetItemText(this->hWnd, index, 0, text, size);
}
VOID ListView::GetSubItemText(UINT index, UINT subindex, LPTSTR text, UINT size)
{
ListView_GetItemText(this->hWnd, index, subindex, text, size);
}
LPARAM ListView::GetItemData(UINT index)
{
LPARAM p = NULL;
LVITEM lvi;
lvi.mask = LVIF_PARAM;
lvi.iItem = index;
lvi.iSubItem = 0;
ListView_GetItem(this->hWnd, &lvi);
return lvi.lParam;
}
UINT ListView::GetSelectedItemIndex()
{
return ListView_GetSelectionMark(this->hWnd);
}
HIMAGELIST ListView::SetNormalImageList(HIMAGELIST himl)
{
return ListView_SetImageList(this->hWnd, himl, LVSIL_NORMAL);
}
HIMAGELIST ListView::SetSmallImageList(HIMAGELIST himl)
{
return ListView_SetImageList(this->hWnd, himl, LVSIL_SMALL);
}