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
|
// ListViewControl.cxx: implementation of the ListViewControl class.
//
//////////////////////////////////////////////////////////////////////
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "ListViewControl.h"
#include "commctrl.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
using namespace rfb;
using namespace rfb::win32;
ListViewControl::ListViewControl()
{
}
bool ListViewControl::IsSelectedLVItem(DWORD idListView,
HWND hDlg, int numberItem)
{
return (ListView_GetItemState(GetDlgItem(hDlg, idListView),
numberItem, LVIS_SELECTED) == LVIS_SELECTED);
}
void ListViewControl::SelectLVItem(DWORD idListView, HWND hDlg, int numberItem)
{
ListView_SetItemState(GetDlgItem(hDlg, idListView),
numberItem, LVIS_SELECTED, LVIS_SELECTED);
}
BOOL ListViewControl::InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns,
char *title[], DWORD mask, DWORD LVStyle, DWORD format)
{
(void)ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle);
char szText[256];
LVCOLUMN lvc;
int iCol;
lvc.mask = mask;
for (iCol = 0; iCol < columns; iCol++) {
lvc.iSubItem = iCol;
lvc.pszText = szText;
lvc.cx = width;
lvc.fmt = format;
strcpy(szText, title[iCol]);
if (ListView_InsertColumn(GetDlgItem(hDlg, idListView), iCol, &lvc) == -1)
return FALSE;
}
return TRUE;
}
BOOL ListViewControl::InsertLVItem(DWORD idListView, HWND hDlg, int number, char * texts[],
int columns)
{
int i;
LVITEM lvI;
lvI.mask = LVIF_TEXT| LVIF_STATE;
lvI.state = 0;
lvI.stateMask = 0;
lvI.iItem = number;
lvI.iSubItem = 0;
lvI.pszText = texts[0];
if(ListView_InsertItem(GetDlgItem(hDlg, idListView), &lvI) == -1)
return FALSE;
for (i =1; i < columns; i++) {
SetLVItemText(
idListView, hDlg,
number, i, texts[i]);
}
return TRUE;
}
void ListViewControl::SetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
int namberColumn, char * text)
{
ListView_SetItemText(
GetDlgItem(hDlg, idListView),
numberItem, namberColumn, text);
}
void ListViewControl::GetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
int namberColumn, char * text)
{
ListView_GetItemText(GetDlgItem(hDlg, idListView), numberItem,
namberColumn, text, 256);
}
void ListViewControl::DeleteLVItem(DWORD idListView, HWND hDlg, int number)
{
(void)ListView_DeleteItem(GetDlgItem(hDlg, idListView), number);
}
void ListViewControl::DeleteAllLVItem(DWORD idListView, HWND hDlg)
{
(void)ListView_DeleteAllItems(GetDlgItem(hDlg, idListView));
}
ListViewControl::~ListViewControl()
{
}
|