forked from bigmacd/trapreceiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrExploderAdd.cpp
More file actions
121 lines (107 loc) · 2.29 KB
/
TrExploderAdd.cpp
File metadata and controls
121 lines (107 loc) · 2.29 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
#include "stdafx.h"
#include "TrExploderAdd.h"
#include "Registry.h"
TrExploderAddDlg::TrExploderAddDlg(CWnd* pParent /*=NULL*/)
:CDialog(TrExploderAddDlg::IDD, pParent),
mInChangeMode(FALSE),
mExploderNumber(-1)
{
//{{AFX_DATA_INIT(TrExploderAddDlg)
mHost = _T("");
mPort = _T("162");
//}}AFX_DATA_INIT
}
TrExploderAddDlg::TrExploderAddDlg(CString host,
CString port)
:CDialog(TrExploderAddDlg::IDD, NULL),
mInChangeMode(TRUE),
mHost(host),
mPort(port)
{
// Registry registry("Exploder", exploderNumber);
// mHost = registry.exploderDestination();
// CString port;
// port.Format("%d", registry.exploderPort());
// mPort = port;
}
void
TrExploderAddDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(TrExploderAddDlg)
DDX_Control(pDX, IDOK, mAddUpdateButton);
DDX_Text(pDX, IDC_EDITHOST, mHost);
DDV_MaxChars(pDX, mHost, 35);
DDX_Text(pDX, IDC_EDITPORT, mPort);
DDV_MaxChars(pDX, mPort, 5);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(TrExploderAddDlg, CDialog)
//{{AFX_MSG_MAP(TrExploderAddDlg)
ON_BN_CLICKED(IDCANCEL, OnButtonClose)
ON_BN_CLICKED(IDOK, OnButtonAdd)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//int
//TrExploderAddDlg::doModal(int nothing)
//{
// mHost.Empty();
// mPort = _T("162");
//
// return CDialog::DoModal();
//}
BOOL
TrExploderAddDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if (mInChangeMode)
mAddUpdateButton.SetWindowText("Update");
else
mAddUpdateButton.SetWindowText("Add");
return TRUE;
}
void
TrExploderAddDlg::OnButtonClose()
{
CDialog::OnCancel();
}
void
TrExploderAddDlg::OnButtonAdd()
{
UpdateData(TRUE);
if (mHost.GetLength() == 0)
{
AfxMessageBox("Incorrect host specified",
MB_OK | MB_ICONEXCLAMATION);
return;
}
else
if (mPort.GetLength() == 0)
{
AfxMessageBox("Incorrect port specified",
MB_OK | MB_ICONEXCLAMATION);
return;
}
else
{
try
{
Registry registry("Exploder");
int port = atoi(mPort.GetBuffer(0));
if (!mInChangeMode)
{
int dummy;
if (registry.find(mHost, port, dummy))
{
AfxMessageBox("Duplicate Entry",
MB_OK | MB_ICONEXCLAMATION);
return;
}
}
}
catch(...)
{
}
}
CDialog::OnOK();
}