-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPasswordDlg.cpp
82 lines (63 loc) · 1.76 KB
/
PasswordDlg.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
// PasswordDlg.cpp : implementation file
//
#include "pch.h"
#include "DatabaseExplorer.h"
#include "PasswordDlg.h"
#include "afxdialogex.h"
void CPasswordDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPasswordDlg)
DDX_Text(pDX, IDC_EDIT_PASS, m_sPass);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPasswordDlg, CDialogEx)
//{{AFX_MSG_MAP(CPasswordDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CPasswordDlg dialog
IMPLEMENT_DYNAMIC(CPasswordDlg, CDialogEx)
CPasswordDlg::CPasswordDlg(BOOL bAdmin, const CString& sDSN, CWnd* pParent/* = nullptr*/)
:CDialogEx(IDD_DIALOG_PASSWORD, pParent)
{
m_bAdmin = bAdmin;
m_sDSN = sDSN;
m_sPass = _T("");
}
CPasswordDlg::~CPasswordDlg()
{
}
// CPasswordDlg message handlers
BOOL CPasswordDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: Add extra initialization here
m_hIcon = AfxGetApp()->LoadIcon(IDI_KEY);
SetIcon(m_hIcon, FALSE);
SendDlgItemMessage(IDC_EDIT_PASS, EM_SETCUEBANNER,
(WPARAM)FALSE, // show only if the edit control has no focus
(LPARAM)L" <<Type your password>>"); // cue banner text
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPasswordDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData();
CString sPath;
sPath.Format(_T("SOFTWARE\\ODBC\\ODBC.INI\\%s"), m_sDSN);
CSettingsStore ss(m_bAdmin, FALSE);
if (! ss.Open(sPath))
{
MessageBox(_T("The registry location could not been open !"), NULL, MB_ICONERROR);
GetDlgItem(IDC_EDIT_PASS)->SetFocus();
return;
}
if (! ss.Write(_T("Password"), m_sPass))
{
MessageBox(_T("The password could not been saved !"), NULL, MB_ICONERROR);
GetDlgItem(IDC_EDIT_PASS)->SetFocus();
return;
}
CDialogEx::OnOK();
}