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
|
#include "StdAfx.h"
#include "ListCtrlFormatter.h"
#include <string>
ListCtrlFormatter::ListCtrlFormatter( CListCtrl &list ) :
m_List( list ),
m_nColNo( 0 )
{
}
ListCtrlFormatter::~ListCtrlFormatter()
{
}
void
ListCtrlFormatter::AddColumn( CString strHeading,
int nWidth,
int nFormat,
int nSubItemNo )
{
LVCOLUMN column;
column.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
column.cx = nWidth;
column.fmt = nFormat;
column.pszText = strHeading.GetBuffer( strHeading.GetLength() );
column.iSubItem = nSubItemNo == -1 ? m_nColNo : nSubItemNo;
column.iImage = 0;
column.iOrder = 0;
VERIFY( m_List.InsertColumn( m_nColNo++, &column ) >= 0 );
strHeading.ReleaseBuffer();
/*
VERIFY( m_List.InsertColumn( m_nColNo++,
strHeading,
nFormat,
nWidth,
nSubItemNo ) >= 0 );
*/
}
void
ListCtrlFormatter::AddColumn( const std::string &strHeading,
int nWidth,
int nFormat,
int nSubItemNo )
{
AddColumn( CString( strHeading.c_str() ), nWidth, nFormat, nSubItemNo );
}
void
ListCtrlFormatter::AddColumn( UINT nIdStringHeading,
int nWidth,
int nFormat,
int nSubItemNo )
{
CString strHeading;
VERIFY( strHeading.LoadString( nIdStringHeading ) );
AddColumn( strHeading, nWidth, nFormat, nSubItemNo );
}
int
ListCtrlFormatter::GetNextColumnIndex() const
{
return m_nColNo;
}
|