-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPingOptsDlg.cpp
115 lines (103 loc) · 2.9 KB
/
PingOptsDlg.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
/******************************************************************************
** (C) Chris Oldwood
**
** MODULE: PINGOPTSDLG.CPP
** COMPONENT: The Application
** DESCRIPTION: CPingOptsDlg class definition.
**
*******************************************************************************
*/
#include "Common.hpp"
#include "PingOptsDlg.hpp"
/******************************************************************************
** Method: Default constructor.
**
** Description: .
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
CPingOptsDlg::CPingOptsDlg()
: CDialog(IDD_PING_OPTIONS)
, m_ebThreads(false, 2)
, m_ebAttempts(false, 2)
, m_ebTimeout(false, 4)
, m_ebInterval(false, 4)
{
DEFINE_CTRL_TABLE
CTRL(IDC_THREADS, &m_ebThreads )
CTRL(IDC_ATTEMPTS, &m_ebAttempts)
CTRL(IDC_TIMEOUT, &m_ebTimeout )
CTRL(IDC_AUTO_PING, &m_ckAutoPing)
CTRL(IDC_INTERVAL, &m_ebInterval)
END_CTRL_TABLE
}
/******************************************************************************
** Method: OnInitDialog()
**
** Description: Initialise the dialog.
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
void CPingOptsDlg::OnInitDialog()
{
// Initialise controls
m_ebThreads.IntValue(m_oConfig.m_nThreads);
m_ebAttempts.IntValue(m_oConfig.m_nAttempts);
m_ebTimeout.IntValue(m_oConfig.m_nWaitTime);
m_ckAutoPing.Check(m_oConfig.m_bAutoPing);
m_ebInterval.IntValue(m_oConfig.m_nAutoInterval);
}
/******************************************************************************
** Method: OnOk()
**
** Description: The OK button was pressed.
**
** Parameters: None.
**
** Returns: true or false.
**
*******************************************************************************
*/
bool CPingOptsDlg::OnOk()
{
// Validate new settings.
if ( (m_ebThreads.TextLength() == 0) || (m_ebThreads.IntValue() == 0) )
{
AlertMsg(TXT("Please enter a valid thread count (1 - 99)."));
m_ebThreads.Focus();
return false;
}
if ( (m_ebAttempts.TextLength() == 0) || (m_ebAttempts.IntValue() == 0) )
{
AlertMsg(TXT("Please enter a valid number of attempts (1 - 99)."));
m_ebAttempts.Focus();
return false;
}
if ( (m_ebTimeout.TextLength() == 0) || (m_ebTimeout.IntValue() == 0) )
{
AlertMsg(TXT("Please enter a valid time out (1 - 9999)."));
m_ebTimeout.Focus();
return false;
}
if ( (m_ebInterval.TextLength() == 0) || (m_ebInterval.IntValue() == 0) )
{
AlertMsg(TXT("Please enter a valid interval (1 - 9999)."));
m_ebInterval.Focus();
return false;
}
// Get new settings.
m_oConfig.m_nThreads = m_ebThreads.IntValue();
m_oConfig.m_nAttempts = m_ebAttempts.IntValue();
m_oConfig.m_nWaitTime = m_ebTimeout.IntValue();
m_oConfig.m_bAutoPing = m_ckAutoPing.IsChecked();
m_oConfig.m_nAutoInterval = m_ebInterval.IntValue();
return true;
}