forked from bigmacd/trapreceiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmailRecipients.cpp
More file actions
172 lines (142 loc) · 3.46 KB
/
EmailRecipients.cpp
File metadata and controls
172 lines (142 loc) · 3.46 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#include "stdafx.h"
#include "traprcvr.h"
#include "EmailRecipients.h"
#include "Registry.h"
EmailRecipients::EmailRecipients(CString list)
:CDialog(EmailRecipients::IDD, NULL),
mInEmailList(list)
{
//{{AFX_DATA_INIT(EmailRecipients)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void
EmailRecipients::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(EmailRecipients)
DDX_Control(pDX, IDC_LIST1, mList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(EmailRecipients, CDialog)
//{{AFX_MSG_MAP(EmailRecipients)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL
EmailRecipients::OnInitDialog()
{
CDialog::OnInitDialog();
//////////////////////////
// 6.40
mList.EnableToolTips(TRUE);
//////////////////////////
RECT rect;
mList.GetClientRect(&rect);
int width = (rect.right) - 5;
mList.InsertColumn(0, "Select", LVCFMT_LEFT, 60);
mList.InsertColumn(1, "Recipient", LVCFMT_LEFT, width - 60);
mList.InsertColumn(2, "id", LVCFMT_LEFT, 0);
ListView_SetExtendedListViewStyle(mList.m_hWnd,
LVS_EX_CHECKBOXES);
// | LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);
Registry registry("Email");
int count = (int)registry.getCount();
try
{
for (int listLength = 0; listLength < count; listLength++)
{
LV_ITEM lv;
lv.mask = LVIF_TEXT;
registry.ReOpen(listLength);
lv.iItem = listLength;
lv.mask = LVIF_TEXT;
lv.iSubItem = 0;
lv.pszText = "";
mList.InsertItem(&lv);
CString data = registry.to();
lv.mask = LVIF_TEXT;
lv.iSubItem = 1;
lv.pszText = data.GetBuffer(0);
mList.SetItem(&lv);
//////////////////////////
// 6.40
CString strItem = _T("From: ");
strItem += _T(registry.from());
strItem += _T(" Subject: ");
strItem += _T(registry.subject());
strItem += _T(" Message: ");
strItem += _T(registry.message());
mList.SetItemToolTipText(listLength, 1, strItem);
//////////////////////////
data.Format("%d", registry.emailId());
CString emailid = data.Right(6);
lv.mask = LVIF_TEXT;
lv.iSubItem = 2;
lv.pszText = emailid.GetBuffer(0);
mList.SetItem(&lv);
if (mInEmailList.Find(emailid) != -1)
mList.SetCheck(listLength);
}
}
catch(...)
{
}
return TRUE;
}
CString
EmailRecipients::EmailList()
{
return mOutEmailList;
}
#if 0
void
EmailRecipients::EmailList(CString list)
{
if (list.GetLength() > 0)
{
// tokenize the list first (comma separated)
char* str = list.GetBuffer(0);
char* comma = NULL;
do
{
comma = strchr(str, ',');
if (comma != NULL)
*comma = 0;
// find the tokens in the list and check them
int listLength = mList.GetItemCount();
for (int x = 0; x < listLength; x++)
{
CString id = mList.GetItemText(x, 2);
if (id == str)
mList.SetCheck(x);
}
if (comma != NULL)
{
*comma = ','; // reset to original value
str = comma;
str++;
}
}
while (comma != NULL);
}
}
#endif
void EmailRecipients::OnOK()
{
// find all the checked items and put them into a comma separated list
mOutEmailList.Empty();
BOOL itemInList = FALSE;
int count = mList.GetItemCount();
for (int x = 0; x < count; x++)
{
if (mList.GetCheck(x))
{
if (itemInList)
mOutEmailList += ',';
itemInList = TRUE;
CString id = mList.GetItemText(x, 2);
mOutEmailList += id;
}
}
CDialog::OnOK();
}