-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMtrAddressPage.cpp
94 lines (83 loc) · 2.13 KB
/
MtrAddressPage.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
/******************************************************************************
** (C) Chris Oldwood
**
** MODULE: MTRADDRESSPAGE.CPP
** COMPONENT: The Application
** DESCRIPTION: CMtrAddressPage class definition.
**
*******************************************************************************
*/
#include "Common.hpp"
#include "MtrAddressPage.hpp"
#include "MasterQueryOpts.hpp"
/******************************************************************************
** Method: Default constructor.
**
** Description: .
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
CMtrAddressPage::CMtrAddressPage(CMasterQueryOpts& oConfig)
: CPropertyPage(IDD_MASTER_ADDRESS)
, m_oConfig(oConfig)
, m_ebPort(false, 5)
{
DEFINE_CTRL_TABLE
CTRL(IDC_ADDRESS, &m_ebAddress)
CTRL(IDC_PORT, &m_ebPort )
END_CTRL_TABLE
DEFINE_CTRLMSG_TABLE
END_CTRLMSG_TABLE
}
/******************************************************************************
** Method: OnInitDialog()
**
** Description: Initialise the dialog.
**
** Parameters: None.
**
** Returns: Nothing.
**
*******************************************************************************
*/
void CMtrAddressPage::OnInitDialog()
{
// Initialise controls.
m_ebAddress.Text(m_oConfig.m_strAddress);
m_ebPort.IntValue(m_oConfig.m_nPort);
}
/******************************************************************************
** Method: OnValidate()
**
** Description: Validate the settings.
**
** Parameters: None.
**
** Returns: true or false.
**
*******************************************************************************
*/
bool CMtrAddressPage::OnValidate()
{
// Validate new settings.
if (m_ebAddress.TextLength() == 0)
{
AlertMsg(TXT("Please enter the server IP address."));
m_ebAddress.Focus();
return false;
}
if ( (m_ebPort.TextLength() == 0) || (m_ebPort.IntValue() > 65535) )
{
AlertMsg(TXT("Please enter a valid IP port number (0 - 65535)."));
m_ebPort.Focus();
return false;
}
// Get new settings.
m_oConfig.m_strAddress = m_ebAddress.Text();
m_oConfig.m_nPort = m_ebPort.IntValue();
return true;
}