summaryrefslogtreecommitdiffstats
path: root/win/rfb_win32/ListViewControl.cxx
blob: bd375e260837e156bc3cedd8bd8249b2f14ecc90 (plain)
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
// ListViewControl.cxx: implementation of the ListViewControl class.
//
//////////////////////////////////////////////////////////////////////
#include <tchar.h>
#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,
                                    TCHAR *title[], DWORD mask, DWORD LVStyle, DWORD format)
{
  ListView_SetExtendedListViewStyle(GetDlgItem(hDlg, idListView), LVStyle);
  TCHAR 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;
    
    _tcscpy(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,  TCHAR * 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, TCHAR * text)
{
  ListView_SetItemText(
    GetDlgItem(hDlg, idListView), 
    numberItem, namberColumn, text);
}

void ListViewControl::GetLVItemText(DWORD idListView, HWND hDlg, int numberItem,
                                    int namberColumn, TCHAR * text)
{
	 ListView_GetItemText(GetDlgItem(hDlg, idListView), numberItem,
							namberColumn, text, 256);
}

void ListViewControl::DeleteLVItem(DWORD idListView, HWND hDlg, int number)
{
  ListView_DeleteItem(GetDlgItem(hDlg, idListView), number);
}

void ListViewControl::DeleteAllLVItem(DWORD idListView, HWND hDlg)
{
  ListView_DeleteAllItems(GetDlgItem(hDlg, idListView));
}

ListViewControl::~ListViewControl()
{
}