-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDlgImportStatus.cpp
193 lines (148 loc) · 4.74 KB
/
DlgImportStatus.cpp
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*//////////////////////////////////////////////////////////////////////////////
// Name: dlgimportstatus.cpp
// Purpose: Implementation of CDlgImportStatus
// Author: Ruediger Herrmann
// Copyright: (c) Ruediger Herrmann
//////////////////////////////////////////////////////////////////////////////*/
#include "stdafx.h"
#include "ECTImportX.h"
#include "easycashdoc.h"
#include "DlgImportStatus.h"
#include "module.h"
#include "helpcontextmap.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CDlgImportStatus::CDlgImportStatus(CWnd* pParent /*=NULL*/)
: CDialog(CDlgImportStatus::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgImportStatus)
//}}AFX_DATA_INIT
}
void CDlgImportStatus::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
if ( !pDX->m_bSaveAndValidate && m_MessagesList.m_hWnd ) {
// clear content
m_MessagesList.DeleteAllItems();
CString LineNoStr;
int i, NewItemIndex;
for ( i = 0; i <= m_Messages.GetSize() - 1; i++ )
{
if ( m_Messages.GetAt ( i )->GetLineNo() == 0 )
{
LineNoStr = _T("");
}
else
{
#pragma warning(disable : 4996)
_itot ( m_Messages.GetAt ( i )->GetLineNo(), LineNoStr.GetBuffer ( 20 ), 10 );
LineNoStr.ReleaseBuffer();
}
NewItemIndex = m_MessagesList.InsertItem ( i, LineNoStr );
m_MessagesList.SetItemText ( NewItemIndex, 1, m_Messages.GetAt ( i )->GetMsg() );
}
}
//{{AFX_DATA_MAP(CDlgImportStatus)
DDX_Control(pDX, IDC_ERRORICON, m_ErrorIcon);
DDX_Control(pDX, IDC_MESSAGES, m_MessagesList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgImportStatus, CDialog)
//{{AFX_MSG_MAP(CDlgImportStatus)
ON_WM_HELPINFO()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CDlgImportStatus::SetMessages ( const CImportErrorList& Value )
{
// copy messages
int i;
for ( i = 0; i <= Value.GetSize() - 1; i++ )
{
m_Messages.Add ( Value.GetAt ( i )->GetLineNo(), Value.GetAt ( i )->GetMsg() );
}
};
BOOL CDlgImportStatus::OnInitDialog()
{
CDialog::OnInitDialog();
// set error icon's image
m_ErrorIcon.SetIcon ( LoadIcon ( NULL, IDI_ERROR ) );
// set listview's extended style and create list columns
m_MessagesList.SetExtendedStyle ( m_MessagesList.GetExtendedStyle() | LVS_EX_FULLROWSELECT );
CString ColumnTitle ( MAKEINTRESOURCE ( IDS_IMPORTSTATUS_ERRORLIST_COL1 ) );
m_MessagesList.InsertColumn ( 0, ColumnTitle, LVCFMT_LEFT, -1, -1 );
ColumnTitle.LoadString ( IDS_IMPORTSTATUS_ERRORLIST_COL2 );
m_MessagesList.InsertColumn ( 1, ColumnTitle, LVCFMT_LEFT, -1, -1 );
//
UpdateData ( FALSE );
//
UpdateColumnWidths();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zurückgeben
}
BOOL CDlgImportStatus::OnHelpInfo(HELPINFO* pHelpInfo) {
char exefilename[MAX_PATH];
char *cp;
if (::GetModuleFileName(theApp.m_hInstance, exefilename, MAX_PATH) && (cp = strrchr(exefilename, '\\')))
{
strcpy(cp, "\\ECTEImport.htm");
::ShellExecute(NULL, "open", exefilename, NULL, NULL, SW_SHOWNORMAL);
}
return CDialog::OnHelpInfo(pHelpInfo);
}
void CDlgImportStatus::UpdateColumnWidths()
{
if ( !m_MessagesList.m_hWnd )
return;
// declare variables
HD_ITEM HeaderItem;
HeaderItem.mask = HDI_TEXT;
int i, Col, ColWidth, MaxColWidth;
CString ColText;
for ( Col = 0; Col <= m_MessagesList.GetHeaderCtrl()->GetItemCount() - 1; Col++ ) {
// get width of header
HeaderItem.pszText = NULL;
m_MessagesList.GetHeaderCtrl()->GetItem ( Col, &HeaderItem );
ColText = HeaderItem.pszText;
MaxColWidth = m_MessagesList.GetStringWidth ( ColText );
// get max width of entries in column
for ( i = 0; i <= m_MessagesList.GetItemCount() - 1; i++ ) {
ColWidth = m_MessagesList.GetStringWidth ( m_MessagesList.GetItemText ( i, Col ) );
if ( ColWidth > MaxColWidth )
MaxColWidth = ColWidth;
}
// set new col width
m_MessagesList.SetColumnWidth ( Col, MaxColWidth + 15 );
}
/*
int ItemWidth, HeaderWidth;
m_MessagesList.GetStringWidth ( ColumnTitle ) + 15
m_MessagesList.SetColumnWidth ( 0, m_MessagesList.GetStringWidth ( ColumnTitle ) + 15 );
*/
}
/*
// DlgImportStatus.cpp : implementation file
//
#include "stdafx.h"
#include "ECTImportX.h"
#include "DlgImportStatus.h"
// CDlgImportStatus dialog
IMPLEMENT_DYNAMIC(CDlgImportStatus, CDialog)
CDlgImportStatus::CDlgImportStatus(CWnd* pParent **=NULL**)
: CDialog(CDlgImportStatus::IDD, pParent)
{
}
CDlgImportStatus::~CDlgImportStatus()
{
}
void CDlgImportStatus::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CDlgImportStatus, CDialog)
END_MESSAGE_MAP()
// CDlgImportStatus message handlers
*/