DialogConfig.cpp
3.4 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
// DialogConfig.cpp : 实现文件
//
#include "stdafx.h"
#include "DialogConfig.h"
#include "afxdialogex.h"
#include "etradeclient/utility/application_config.h"
#include "resource.h"
const int CLIENT_HEIGHT = 200;
const int CLIENT_WIDTH = 300;
const int CLIENT_SPACE = 10;
const int STATIC_HEIGHT = 20;
const int STATIC_WIDTH = 60;
const int EDIT_HEIGHT = 18;
const int EDIT_WIDTH = 60;
const int BUTTON_HEIGHT = 30;
const int BUTTON_WIDTH = 80;
// CDialogConfig 对话框
IMPLEMENT_DYNAMIC(CDialogConfig, CDialogEx)
CDialogConfig::CDialogConfig(CWnd* pParent /*=NULL*/)
: CDialogEx(CDialogConfig::IDD, pParent),
m_iPinPadPWLen(0), m_iPinPadTimeout(0)
{
}
CDialogConfig::~CDialogConfig()
{
}
void CDialogConfig::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
const int kMinTimeoutSeconds = 1, kMaxTimeoutSeconds = 10;
const int kMinPwdLen = 6, kMaxPwdLen = 32;
DDX_Text(pDX, IDC_EDIT_PIN_PAD_LEN, m_iPinPadPWLen);
DDV_MinMaxInt(pDX, m_iPinPadPWLen, kMinPwdLen, kMaxPwdLen);
DDX_Text(pDX, IDC_EDIT_PIN_PAD_TIMEOUT, m_iPinPadTimeout);
DDV_MinMaxInt(pDX, m_iPinPadTimeout, kMinTimeoutSeconds, kMaxTimeoutSeconds);
}
BEGIN_MESSAGE_MAP(CDialogConfig, CDialogEx)
ON_BN_CLICKED(IDOK, &CDialogConfig::OnBnClickedOk)
END_MESSAGE_MAP()
// CDialogConfig 消息处理程序
BOOL CDialogConfig::OnInitDialog()
{
CDialogEx::OnInitDialog();
CRect rtClient;
GetWindowRect(&rtClient);
MoveWindow(rtClient.left, rtClient.top, CLIENT_WIDTH, CLIENT_HEIGHT);
GetClientRect(&rtClient);
GetDlgItem(IDC_STATIC_PINPAD)->MoveWindow(rtClient.left + CLIENT_SPACE, rtClient.top + CLIENT_SPACE,
rtClient.Width() - CLIENT_SPACE * 2, rtClient.Height() - CLIENT_SPACE * 2 - BUTTON_HEIGHT);
GetDlgItem(IDC_STATIC_LEN)->MoveWindow(rtClient.left + CLIENT_SPACE * 5,
rtClient.top + CLIENT_SPACE * 4 + 2,
STATIC_WIDTH, STATIC_HEIGHT);
GetDlgItem(IDC_EDIT_PIN_PAD_LEN)->MoveWindow(rtClient.left + CLIENT_SPACE * 5 + STATIC_WIDTH,
rtClient.top + CLIENT_SPACE * 4,
EDIT_WIDTH, EDIT_HEIGHT);
GetDlgItem(IDC_STATIC_TIMEOUT)->MoveWindow(rtClient.left + CLIENT_SPACE * 5,
rtClient.top + CLIENT_SPACE * 5 + STATIC_HEIGHT + 2,
STATIC_WIDTH, STATIC_HEIGHT);
GetDlgItem(IDC_EDIT_PIN_PAD_TIMEOUT)->MoveWindow(rtClient.left + CLIENT_SPACE * 5 + STATIC_WIDTH,
rtClient.top + CLIENT_SPACE * 5 + STATIC_HEIGHT,
EDIT_WIDTH, EDIT_HEIGHT);
GetDlgItem(IDC_STATIC_SECOND)->MoveWindow(rtClient.left + CLIENT_SPACE * 6 + STATIC_WIDTH + EDIT_WIDTH,
rtClient.top + CLIENT_SPACE * 5 + STATIC_HEIGHT + 2,
STATIC_WIDTH, STATIC_HEIGHT);
GetDlgItem(IDCANCEL)->MoveWindow(rtClient.right - BUTTON_WIDTH, rtClient.bottom - BUTTON_HEIGHT,
BUTTON_WIDTH, BUTTON_HEIGHT);
GetDlgItem(IDOK)->MoveWindow(rtClient.right - BUTTON_WIDTH * 2 - CLIENT_SPACE,
rtClient.bottom - BUTTON_HEIGHT,
BUTTON_WIDTH, BUTTON_HEIGHT);
const ApplicationConfig& app_config = ApplicationConfig::Instance();
m_iPinPadPWLen = app_config.PINPadPWDLen();
m_iPinPadTimeout = app_config.PINPadTimeout();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CDialogConfig::OnBnClickedOk()
{
UpdateData(TRUE);
const ApplicationConfig& app_config = ApplicationConfig::Instance();
ApplicationConfig::Instance().ModifyCfg(
app_config.MsgCountQueryInterval(),
app_config.PWDMachineIP(),
app_config.PWDMachinePort(),
app_config.PWDMachineTimeout(),
m_iPinPadPWLen,
m_iPinPadTimeout);
CDialogEx::OnOK();
}