Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[r5083]: tags / V3_12 / OptionsMisc.cpp Maximize Restore History

Download this file

OptionsMisc.cpp    259 lines (220 with data), 8.1 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
/*
* Copyright (c) 2003-2008 Rony Shapiro <ronys@users.sourceforge.net>.
* All rights reserved. Use of the code is allowed under the
* Artistic License 2.0 terms, as specified in the LICENSE file
* distributed with this code, or available from
* http://www.opensource.org/licenses/artistic-license-2.0.php
*/
// OptionsMisc.cpp : implementation file
//
#include "stdafx.h"
#include "passwordsafe.h"
#include "corelib/PwsPlatform.h"
#include "corelib/PWSprefs.h" // for DoubleClickAction enums
#if defined(POCKET_PC)
#include "pocketpc/resource.h"
#else
#include "resource.h"
#include "resource3.h" // String resources
#endif
#include "OptionsMisc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COptionsMisc property page
IMPLEMENT_DYNCREATE(COptionsMisc, CPropertyPage)
COptionsMisc::COptionsMisc()
: CPWPropertyPage(COptionsMisc::IDD), m_ToolTipCtrl(NULL)
{
//{{AFX_DATA_INIT(COptionsMisc)
//}}AFX_DATA_INIT
}
COptionsMisc::~COptionsMisc()
{
delete m_ToolTipCtrl;
}
void COptionsMisc::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptionsMisc)
DDX_Check(pDX, IDC_CONFIRMDELETE, m_confirmdelete);
DDX_Check(pDX, IDC_MAINTAINDATETIMESTAMPS, m_maintaindatetimestamps);
DDX_Check(pDX, IDC_ESC_EXITS, m_escexits);
DDX_Control(pDX, IDC_DOUBLE_CLICK_ACTION, m_dblclk_cbox);
DDX_Check(pDX, IDC_HOTKEY_ENABLE, m_hotkey_enabled);
// JHF class CHotKeyCtrl not defined under WinCE
#if !defined(POCKET_PC)
DDX_Control(pDX, IDC_HOTKEY_CTRL, m_hotkey);
#endif
DDX_Check(pDX, IDC_USEDEFUSER, m_usedefuser);
DDX_Check(pDX, IDC_QUERYSETDEF, m_querysetdef);
DDX_Text(pDX, IDC_DEFUSERNAME, m_defusername);
DDX_Text(pDX, IDC_OTHERBROWSERLOCATION, m_otherbrowserlocation);
DDX_Text(pDX, IDC_ALTBROWSER_CMDLINE, m_csBrowserCmdLineParms);
DDX_Text(pDX, IDC_DEFAULTAUTOTYPE, m_csAutotype);
DDX_Check(pDX, IDC_MINIMIZEONAUTOTYPE, m_minauto);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COptionsMisc, CPropertyPage)
//{{AFX_MSG_MAP(COptionsMisc)
ON_BN_CLICKED(IDC_HOTKEY_ENABLE, OnEnableHotKey)
ON_BN_CLICKED(IDC_USEDEFUSER, OnUsedefuser)
ON_BN_CLICKED(IDC_BROWSEFORLOCATION, OnBrowseForLocation)
ON_CBN_SELCHANGE(IDC_DOUBLE_CLICK_ACTION, OnComboChanged)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL COptionsMisc::OnInitDialog()
{
CPropertyPage::OnInitDialog();
// For some reason, MFC calls us twice when initializing.
// Populate the combo box only once.
if(m_dblclk_cbox.GetCount() == 0) {
// add the strings in alphabetical order
int nIndex;
CString cs_text;
cs_text.LoadString(IDS_DCAAUTOTYPE);
nIndex = m_dblclk_cbox.AddString(cs_text);
m_dblclk_cbox.SetItemData(nIndex, PWSprefs::DoubleClickAutoType);
m_DCA_to_Index[PWSprefs::DoubleClickAutoType] = nIndex;
cs_text.LoadString(IDS_DCABROWSE);
nIndex = m_dblclk_cbox.AddString(cs_text);
m_dblclk_cbox.SetItemData(nIndex, PWSprefs::DoubleClickBrowse);
m_DCA_to_Index[PWSprefs::DoubleClickBrowse] = nIndex;
cs_text.LoadString(IDS_DCACOPYNOTES);
nIndex = m_dblclk_cbox.AddString(cs_text);
m_dblclk_cbox.SetItemData(nIndex, PWSprefs::DoubleClickCopyNotes);
m_DCA_to_Index[PWSprefs::DoubleClickCopyNotes] = nIndex;
cs_text.LoadString(IDS_DCACOPYPASSWORD);
nIndex = m_dblclk_cbox.AddString(cs_text);
m_dblclk_cbox.SetItemData(nIndex, PWSprefs::DoubleClickCopyPassword);
m_DCA_to_Index[PWSprefs::DoubleClickCopyPassword] = nIndex;
cs_text.LoadString(IDS_DCACOPYUSERNAME);
nIndex = m_dblclk_cbox.AddString(cs_text);
m_dblclk_cbox.SetItemData(nIndex, PWSprefs::DoubleClickCopyUsername);
m_DCA_to_Index[PWSprefs::DoubleClickCopyUsername] = nIndex;
cs_text.LoadString(IDS_DCAVIEWEDIT);
nIndex = m_dblclk_cbox.AddString(cs_text);
m_dblclk_cbox.SetItemData(nIndex, PWSprefs::DoubleClickViewEdit);
m_DCA_to_Index[PWSprefs::DoubleClickViewEdit] = nIndex;
}
if (m_doubleclickaction < PWSprefs::minDCA ||
m_doubleclickaction > PWSprefs::maxDCA)
m_doubleclickaction = PWSprefs::DoubleClickCopyPassword;
m_dblclk_cbox.SetCurSel(m_DCA_to_Index[m_doubleclickaction]);
// JHF ditto here
#if !defined(POCKET_PC)
m_hotkey.SetHotKey(LOWORD(m_hotkey_value),HIWORD(m_hotkey_value));
if (m_hotkey_enabled == FALSE)
m_hotkey.EnableWindow(FALSE);
#endif
GetDlgItem(IDC_OTHERBROWSERLOCATION)->SetWindowText(m_csBrowser);
OnUsedefuser();
// Tooltips on Property Pages
EnableToolTips();
m_ToolTipCtrl = new CToolTipCtrl;
if (!m_ToolTipCtrl->Create(this, TTS_ALWAYSTIP | TTS_BALLOON | TTS_NOPREFIX)) {
TRACE("Unable To create Property Page ToolTip\n");
return TRUE;
}
// Activate the tooltip control.
m_ToolTipCtrl->Activate(TRUE);
m_ToolTipCtrl->SetMaxTipWidth(300);
// Set the tooltip
// Note naming convention: string IDS_xxx corresponds to control IDC_xxx
CString cs_ToolTip;
cs_ToolTip.LoadString(IDS_MAINTAINDATETIMESTAMPS);
m_ToolTipCtrl->AddTool(GetDlgItem(IDC_MAINTAINDATETIMESTAMPS), cs_ToolTip);
cs_ToolTip.LoadString(IDS_OTHERBROWSERLOCATION);
m_ToolTipCtrl->AddTool(GetDlgItem(IDC_OTHERBROWSERLOCATION), cs_ToolTip);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// COptionsMisc message handlers
void COptionsMisc::OnEnableHotKey()
{
// JHF : no hotkeys on WinCE
#if !defined(POCKET_PC)
if (((CButton*)GetDlgItem(IDC_HOTKEY_ENABLE))->GetCheck() == 1) {
GetDlgItem(IDC_HOTKEY_CTRL)->EnableWindow(TRUE);
GetDlgItem(IDC_HOTKEY_CTRL)->SetFocus();
} else
GetDlgItem(IDC_HOTKEY_CTRL)->EnableWindow(FALSE);
#endif
}
void COptionsMisc::OnComboChanged()
{
int nIndex = m_dblclk_cbox.GetCurSel();
m_doubleclickaction = m_dblclk_cbox.GetItemData(nIndex);
}
void COptionsMisc::OnUsedefuser()
{
if (((CButton*)GetDlgItem(IDC_USEDEFUSER))->GetCheck() == 1) {
GetDlgItem(IDC_DEFUSERNAME)->EnableWindow(TRUE);
GetDlgItem(IDC_STATIC_USERNAME)->EnableWindow(TRUE);
GetDlgItem(IDC_QUERYSETDEF)->EnableWindow(FALSE);
} else {
GetDlgItem(IDC_DEFUSERNAME)->EnableWindow(FALSE);
GetDlgItem(IDC_STATIC_USERNAME)->EnableWindow(FALSE);
GetDlgItem(IDC_QUERYSETDEF)->EnableWindow(TRUE);
}
}
void COptionsMisc::OnOK()
{
UpdateData(TRUE);
// JHF ditto
#if !defined(POCKET_PC)
WORD wVirtualKeyCode, wModifiers;
m_hotkey.GetHotKey(wVirtualKeyCode, wModifiers);
DWORD v = wVirtualKeyCode | (wModifiers << 16);
m_hotkey_value = v;
#endif
m_csBrowser = m_otherbrowserlocation;
CPropertyPage::OnOK();
}
void COptionsMisc::OnBrowseForLocation()
{
CString cs_initiallocation, cs_title;
TCHAR path_buffer[_MAX_PATH];
TCHAR drive[_MAX_DRIVE];
TCHAR dir[_MAX_DIR];
INT_PTR rc;
if (m_csBrowser.IsEmpty())
cs_initiallocation = _T("C:\\");
else {
#if _MSC_VER >= 1400
_tsplitpath_s(m_csBrowser, drive, _MAX_DRIVE, dir, _MAX_DIR, NULL, 0, NULL, 0);
_tmakepath_s(path_buffer, _MAX_PATH, drive, dir, NULL, NULL);
#else
_tsplitpath(m_csBrowser, drive, dir, NULL, NULL);
_tmakepath(path_buffer, drive, dir, NULL, NULL);
#endif
cs_initiallocation = CString(path_buffer);
}
CFileDialog fd(TRUE, NULL, NULL,
OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_DONTADDTORECENT |
OFN_HIDEREADONLY | OFN_PATHMUSTEXIST,
_T("Programs (*.exe)|*.exe|")
_T("All files (*.*)|*.*|")
_T("|"),
this);
cs_title.LoadString(IDS_SELECTBROWSER);
fd.m_ofn.lpstrTitle = cs_title;
fd.m_ofn.lpstrInitialDir = cs_initiallocation;
rc = fd.DoModal();
if (rc == IDOK) {
m_csBrowser = fd.GetPathName();
GetDlgItem(IDC_OTHERBROWSERLOCATION)->SetWindowText(m_csBrowser);
}
}
// Override PreTranslateMessage() so RelayEvent() can be
// called to pass a mouse message to CPWSOptions's
// tooltip control for processing.
BOOL COptionsMisc::PreTranslateMessage(MSG* pMsg)
{
if (m_ToolTipCtrl != NULL)
m_ToolTipCtrl->RelayEvent(pMsg);
return CPropertyPage::PreTranslateMessage(pMsg);
}