forked from morbac/xmltools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionsDlg.cpp
113 lines (86 loc) · 3.31 KB
/
OptionsDlg.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
// OptionsDlg.cpp : fichier d'implémentation
//
#include "stdafx.h"
#include "XMLTools.h"
#include "OptionsDlg.h"
#include "afxdialogex.h"
#include <string>
// Boîte de dialogue COptionsDlg
IMPLEMENT_DYNAMIC(COptionsDlg, CDialogEx)
COptionsDlg::COptionsDlg(CWnd* pParent /*=NULL*/, struct struct_proxyoptions* proxyoptions /*=NULL*/)
: CDialogEx(COptionsDlg::IDD, pParent)
{
this->proxyoptions = proxyoptions;
}
COptionsDlg::~COptionsDlg()
{
}
void COptionsDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDITPROXYHOST, editProxyHost);
DDX_Control(pDX, IDC_EDITPROXYPORT, editProxyPort);
DDX_Control(pDX, IDC_EDITPROXYUSERNAME, editProxyUsername);
DDX_Control(pDX, IDC_EDITPROXYPASSWORD, editProxyPassword);
}
BEGIN_MESSAGE_MAP(COptionsDlg, CDialogEx)
ON_BN_CLICKED(IDC_CHKENABLEPROXY, &COptionsDlg::OnBnClickedChkenableproxy)
ON_BN_CLICKED(IDOK, &COptionsDlg::OnBnClickedOk)
END_MESSAGE_MAP()
// Gestionnaires de messages de COptionsDlg
BOOL COptionsDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
if (this->proxyoptions != NULL) {
if (this->proxyoptions->status) {
((CButton*) GetDlgItem(IDC_CHKENABLEPROXY))->SetCheck(BST_CHECKED);
} else {
((CButton*) GetDlgItem(IDC_CHKENABLEPROXY))->SetCheck(BST_UNCHECKED);
}
GetDlgItem(IDC_EDITPROXYHOST)->SetWindowTextW(this->proxyoptions->host);
GetDlgItem(IDC_EDITPROXYPORT)->SetWindowTextW(std::to_wstring(static_cast<long long>(this->proxyoptions->port)).c_str());
//GetDlgItem(IDC_EDITPROXYUSERNAME)->SetWindowTextW(this->proxyoptions->username);
//GetDlgItem(IDC_EDITPROXYPASSWORD)->SetWindowTextW(this->proxyoptions->password);
}
updateEditFieldsStatus();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION : les pages de propriétés OCX devraient retourner FALSE
}
void COptionsDlg::updateEditFieldsStatus() {
switch(((CButton*) GetDlgItem(IDC_CHKENABLEPROXY))->GetCheck()) {
case BST_UNCHECKED: {
GetDlgItem(IDC_EDITPROXYHOST)->EnableWindow(FALSE);
GetDlgItem(IDC_EDITPROXYPORT)->EnableWindow(FALSE);
//GetDlgItem(IDC_EDITPROXYUSERNAME)->EnableWindow(FALSE);
//GetDlgItem(IDC_EDITPROXYPASSWORD)->EnableWindow(FALSE);
break;
}
case BST_CHECKED: {
GetDlgItem(IDC_EDITPROXYHOST)->EnableWindow(TRUE);
GetDlgItem(IDC_EDITPROXYPORT)->EnableWindow(TRUE);
//GetDlgItem(IDC_EDITPROXYUSERNAME)->EnableWindow(TRUE);
//GetDlgItem(IDC_EDITPROXYPASSWORD)->EnableWindow(TRUE);
GetDlgItem(IDC_EDITPROXYHOST)->SetFocus();
break;
}
}
}
void COptionsDlg::OnBnClickedChkenableproxy() {
updateEditFieldsStatus();
}
void COptionsDlg::OnBnClickedOk()
{
if (this->proxyoptions != NULL) {
this->proxyoptions->status = (((CButton*) GetDlgItem(IDC_CHKENABLEPROXY))->GetCheck() == BST_CHECKED);
CString buffer;
this->editProxyHost.GetWindowText(buffer);
wcscpy_s(this->proxyoptions->host, (const WCHAR *)buffer);
this->editProxyPort.GetWindowText(buffer);
this->proxyoptions->port = _wtoi((LPCTSTR)buffer);
//this->editProxyUsername.GetWindowText(buffer);
//wcscpy_s(this->proxyoptions->username, (const WCHAR *)buffer);
//this->editProxyPassword.GetWindowText(buffer);
//wcscpy_s(this->proxyoptions->password, (const WCHAR *)buffer);
}
CDialogEx::OnOK();
}