-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDlg_Password.cpp
More file actions
279 lines (203 loc) · 15.3 KB
/
Copy pathDlg_Password.cpp
File metadata and controls
279 lines (203 loc) · 15.3 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/**********************************************************************
** Copyright (C) 2005-2015 Tesline-Service S.R.L. All rights reserved.
**
** Rohos Disk Browser, Rohos Mini Drive Portable.
**
**
** This file may be distributed and/or modified under the terms of the
** GNU Affero General Public license version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. If not, see <http://www.gnu.org/licenses/>
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.rohos.com/ for GPL licensing information.
**
** Contact info@rohos.com http://rohos.com
**/
#include "stdafx.h"
#include "DiskBrowserApp.h"
#include "Dlg_Password.h"
#include "XKeyboard.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlg_Password dialog
CDlg_Password::CDlg_Password(CWnd* pParent /*=NULL*/)
: CDialog(CDlg_Password::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlg_Password)
m_password = _T("");
m_lbEnterPassword = _T("");
m_lbImagePath = _T("");
//}}AFX_DATA_INIT
m_FullPath = _T("");
myFileDialog = new CFileDialog(TRUE);
}
void CDlg_Password::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg_Password)
DDX_Text(pDX, IDC_EDIT1, m_password);
//DDX_Text(pDX, IDC_FULL_PATH, m_FullPath);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlg_Password, CDialog)
//{{AFX_MSG_MAP(CDlg_Password)
ON_BN_CLICKED(IDC_BUTTON1, OnVirtualKey)
//}}AFX_MSG_MAP
ON_CBN_SELCHANGE(IDC_COMBO1, &CDlg_Password::OnCbnSelchangeCombo1)
ON_BN_CLICKED(IDC_BUTTON3, &CDlg_Password::OnBnClickedBrowseFile)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlg_Password message handlers
void CDlg_Password::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
TCHAR _disk_image_path[600];
GetDlgItemText( IDC_COMBO1, _disk_image_path, 590); // èìÿ äèñêà äëÿ ìîíòèðîâàíèÿ
m_FullPath = _disk_image_path;
if ( m_vk_passw.GetLength() )
m_password = m_vk_passw; // get virtual keyboard passwrod here
}
void CDlg_Password::OnVirtualKey()
{
CPoint point;
GetCursorPos(&point);
CXKeyboard dlg;//(/*point.x, point.y-127*/);
dlg.SetShowText(false);
//dlg.SetMRUPasswords(sa);
dlg.SetMinLength(1);
dlg.SetMaxLength(25);
//dlg.SetTimeout(23);
//dlg.SetSpecial((CXKeyboard::SPECIAL_CHARACTERS)m_nSpecial);
dlg.SetShowSpacebar(1);
//dlg.SetCase((CXKeyboard::XKEYBOARD_CASE)m_nCase);
dlg.SetPassword("");
//dlg.SetReadOnly(TRUE);
int rc = dlg.DoModal();
if (rc == IDOK)
{
m_vk_passw = dlg.GetPassword();
m_password = "********";
UpdateData(false);
Sleep(300);
OnOK();
}
else if (rc == IDABORT)
{
}
else
{
}
}
BOOL CDlg_Password::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText( LS(IDS_PASSWORD_DLG) );
SetDlgItemText(IDC_LABEL_ENTER_PASS, LS(IDS_ENTER_PASSW) );
SetDlgItemText(IDC_STATIC1, LS(IDS_DISK_FOLDER) );
SetDlgItemText(IDCANCEL, LS(IDS_CANCEL) );
CWnd* pEdit = GetDlgItem(IDC_COMBO1)->GetDlgItem(1001); // edit box inside ComboBox
if( pEdit )
{
SHAutoComplete( pEdit->m_hWnd, SHACF_FILESYSTEM | SHACF_AUTOAPPEND_FORCE_OFF);
}
//m_lbImagePath =
// TODO: Add extra initialization here
int selectionIdx=0;
for (int i=0; i<_possible_disk_images_arr.GetSize(); i++) {
int intemidx = SendDlgItemMessage( IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)_possible_disk_images_arr.GetAt(i) );
if ( _possible_disk_images_arr.GetAt(i) == m_FullPath)
SendDlgItemMessage( IDC_COMBO1, CB_SETCURSEL, intemidx, 0L );
if (_possible_disk_images_arr.GetAt(i).Find(".rdi")>0 )
selectionIdx = intemidx;
}
if (_possible_disk_images_arr.GetSize() == 0)
{
SendDlgItemMessage( IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"..." );
int intemidx = SendDlgItemMessage( IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)m_FullPath );
SendDlgItemMessage(IDC_COMBO1, CB_SETCURSEL, intemidx, 0L );
}
if ( SendDlgItemMessage( IDC_COMBO1, CB_GETCURSEL, 0L, 0L ) == -1)
{
SendDlgItemMessage( IDC_COMBO1, CB_SETCURSEL, selectionIdx, 0L );
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlg_Password::AddPossibleDiskImage(LPCTSTR imagepath)
{
_possible_disk_images_arr.Add(imagepath);
}
void CDlg_Password::AddPossibleDiskImageAtBegin(LPCTSTR imagepath)
{
_possible_disk_images_arr.InsertAt(0, imagepath);
}
void CDlg_Password::OnCbnSelchangeCombo1()
{
int cursel = SendDlgItemMessage( IDC_COMBO1, CB_GETCURSEL, 0, 0L );
TCHAR text[500] = {0};
SendDlgItemMessage( IDC_COMBO1, CB_GETLBTEXT, cursel, (LPARAM)(LPCTSTR)text );
if ( _tcsstr(text, "...") == NULL ) {
m_FullPath= text;
return;
}
return;
/*
// user selected "..." - open file selection dialog
CString file;
TCHAR filter[105];
memset(filter, 0, sizeof(TCHAR)*101 );
LoadString(AfxGetApp()->m_hInstance, IDS_ALLFILES_FILTER, filter, 100);
CString title;
title = LS(IDS_SELECT_FILE_IMAGE);
//myFileDialog->m_ofn.Flags = 0 | OFN_ENABLEHOOK |OFN_EXPLORER | OFN_ENABLESIZING | OFN_PATHMUSTEXIST |OFN_FILEMUSTEXIST | OFN_FORCESHOWHIDDEN;
myFileDialog->m_ofn.Flags = OFN_PATHMUSTEXIST |OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING | OFN_FORCESHOWHIDDEN;
myFileDialog->m_ofn.hwndOwner = m_hWnd;
myFileDialog->m_ofn.lpstrFilter = (LPCTSTR)filter;
myFileDialog->m_ofn.lpstrTitle = (LPCTSTR)title;
//if (_traveler_USB_drive.GetLength() )
//myFileDialog->m_ofn.lpstrInitialDir = (LPCTSTR)_traveler_USB_drive;
CString image_path, image_file_name;
if (myFileDialog->DoModal() == IDOK) {
m_FullPath= myFileDialog->GetPathName();
AddPossibleDiskImage(m_FullPath);
int intemidx = SendDlgItemMessage( IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)m_FullPath );
SendDlgItemMessage( IDC_COMBO1, CB_SETCURSEL, intemidx, 0L );
} else
return;
*/
//if ( 0 == FillListBox("") )
// AfxMessageBox("There are no configured USb Keys.", MB_ICONINFORMATION);
}
void CDlg_Password::OnBnClickedBrowseFile()
{
// user selected "..." - open file selection dialog
CString file;
TCHAR filter[105];
memset(filter, 0, sizeof(TCHAR)*101 );
LoadString(AfxGetApp()->m_hInstance, IDS_ALLFILES_FILTER, filter, 100);
CString title;
title = LS(IDS_SELECT_FILE_IMAGE);
//myFileDialog->m_ofn.Flags = 0 | OFN_ENABLEHOOK |OFN_EXPLORER | OFN_ENABLESIZING | OFN_PATHMUSTEXIST |OFN_FILEMUSTEXIST | OFN_FORCESHOWHIDDEN;
myFileDialog->m_ofn.Flags = OFN_PATHMUSTEXIST |OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING | OFN_FORCESHOWHIDDEN;
myFileDialog->m_ofn.hwndOwner = m_hWnd;
myFileDialog->m_ofn.lpstrFilter = (LPCTSTR)filter;
myFileDialog->m_ofn.lpstrTitle = (LPCTSTR)title;
//if (_traveler_USB_drive.GetLength() )
//myFileDialog->m_ofn.lpstrInitialDir = (LPCTSTR)_traveler_USB_drive;
CString image_path, image_file_name;
if (myFileDialog->DoModal() == IDOK) {
m_FullPath= myFileDialog->GetPathName();
AddPossibleDiskImage(m_FullPath);
int intemidx = SendDlgItemMessage( IDC_COMBO1, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)m_FullPath );
SendDlgItemMessage( IDC_COMBO1, CB_SETCURSEL, intemidx, 0L );
} else
return;
}