Encryption.cpp
2.64 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
// Encryption.cpp : implementation file
//
#include "stdafx.h"
#include "SN Writer.h"
#include "Encryption.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Encryption dialog
char g_cPwd[52] = {0};
Encryption::Encryption(CWnd* pParent /*=NULL*/)
: CDialog(Encryption::IDD, pParent)
{
//{{AFX_DATA_INIT(Encryption)
m_strPwdData = _T("");
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void Encryption::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Encryption)
DDX_Text(pDX, IDC_PWD_DATA, m_strPwdData);
DDV_MaxChars(pDX, m_strPwdData, 32);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Encryption, CDialog)
//{{AFX_MSG_MAP(Encryption)
ON_EN_KILLFOCUS(IDC_PWD_DATA, OnKillfocusPwdData)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Encryption message handlers
void Encryption::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void Encryption::OnOK()
{
// TODO: Add extra validation here
bool bCheckPass = false;
// TODO: Add extra validation here
if(strlen(m_strPwdData) >= 1)
bCheckPass = true;
if(! bCheckPass)
{
SetDlgItemText(IDC_PWD_MSG, "EMPTY INPUT !");
SetDlgItemText(IDC_PWD_DATA, "");
GotoDlgCtrl(GetDlgItem(IDC_PWD_DATA));
}
else
{
CDialog::OnOK();
}
//CDialog::OnOK();
}
void Encryption::OnKillfocusPwdData()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
bool bCheckPass = false;
strncpy(g_cPwd, (LPCTSTR)m_strPwdData, strlen(m_strPwdData)+1);
if(strlen(m_strPwdData) >= 1)
bCheckPass = true;
if(! bCheckPass)
{
SetDlgItemText(IDC_PWD_MSG, "EMPTY INPUT !");
SetDlgItemText(IDC_PWD_DATA, "");
GotoDlgCtrl(GetDlgItem(IDC_PWD_DATA));
}
}
BOOL Encryption::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message == WM_KEYDOWN && pMsg->wParam==VK_RETURN)
{
//AfxMessageBox("hello just for test");
//m_strPwdData += "\n";
UpdateData(true);
OnOK();
return true;
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL Encryption::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
GotoDlgCtrl(GetDlgItem(IDC_PWD_DATA));
return FALSE;
//return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}