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

[bcbb26]: OptionsSystem.cpp Maximize Restore History

Download this file

OptionsSystem.cpp    193 lines (155 with data), 5.7 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
/*
* Copyright (c) 2003-2007 Rony Shapiro <ronys@users.sourceforge.net>.
* All rights reserved. Use of the code is allowed under the
* Artistic License terms, as specified in the LICENSE file
* distributed with this code, or available from
* http://www.opensource.org/licenses/artistic-license.php
*/
// OptionsSystem.cpp : implementation file
//
#include "stdafx.h"
#include "passwordsafe.h"
#include "corelib/PwsPlatform.h"
#include "corelib/PWSprefs.h"
#if defined(POCKET_PC)
#include "pocketpc/resource.h"
#else
#include "resource.h"
#include "resource2.h" // Menu, Toolbar & Accelerator resources
#include "resource3.h" // String resources
#endif
#include "OptionsSystem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// COptionsSystem property page
IMPLEMENT_DYNCREATE(COptionsSystem, CPropertyPage)
COptionsSystem::COptionsSystem() : CPropertyPage(COptionsSystem::IDD)
{
//{{AFX_DATA_INIT(COptionsSystem)
//}}AFX_DATA_INIT
m_ToolTipCtrl = NULL;
m_deleteregistry = FALSE;
}
COptionsSystem::~COptionsSystem()
{
delete m_ToolTipCtrl;
}
void COptionsSystem::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COptionsSystem)
DDX_Text(pDX, IDC_MAXREITEMS, m_maxreitems);
DDV_MinMaxInt(pDX, m_maxreitems, 0, ID_TRAYRECENT_ENTRYMAX - ID_TRAYRECENT_ENTRY1 + 1);
DDX_Check(pDX, IDC_DEFPWUSESYSTRAY, m_usesystemtray);
DDX_Check(pDX, IDC_STARTUP, m_startup);
DDX_Text(pDX, IDC_MAXMRUITEMS, m_maxmruitems);
DDV_MinMaxInt(pDX, m_maxmruitems, 0, ID_FILE_MRU_ENTRYMAX - ID_FILE_MRU_ENTRY1 + 1);
DDX_Check(pDX, IDC_MRU_ONFILEMENU, m_mruonfilemenu);
DDX_Check(pDX, IDC_REGDEL_CB, m_deleteregistry);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COptionsSystem, CPropertyPage)
//{{AFX_MSG_MAP(COptionsSystem)
ON_BN_CLICKED(IDC_DEFPWUSESYSTRAY, OnUseSystemTray)
ON_BN_CLICKED(IDC_STARTUP, OnStartup)
ON_BN_CLICKED(IDC_REGDEL_CB, OnSetDeleteRegistry)
ON_BN_CLICKED(IDC_REGDEL_BTN, OnApplyRegistryDeleteNow)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COptionsSystem message handlers
void COptionsSystem::OnUseSystemTray()
{
BOOL enable = (((CButton*)GetDlgItem(IDC_DEFPWUSESYSTRAY))->GetCheck() ==
BST_CHECKED) ? TRUE : FALSE;
GetDlgItem(IDC_STATIC_MAXREITEMS)->EnableWindow(enable);
GetDlgItem(IDC_MAXREITEMS)->EnableWindow(enable);
GetDlgItem(IDC_RESPIN)->EnableWindow(enable);
}
void COptionsSystem::OnStartup()
{
// Startup implies System tray
bool enable = ((CButton*)GetDlgItem(IDC_STARTUP))->GetCheck() == BST_CHECKED;
if (enable) {
((CButton*)GetDlgItem(IDC_DEFPWUSESYSTRAY))->SetCheck(BST_CHECKED);
GetDlgItem(IDC_STATIC_MAXREITEMS)->EnableWindow(TRUE);
GetDlgItem(IDC_MAXREITEMS)->EnableWindow(TRUE);
GetDlgItem(IDC_RESPIN)->EnableWindow(TRUE);
}
}
void COptionsSystem::OnSetDeleteRegistry()
{
BOOL enable = (((CButton*)GetDlgItem(IDC_REGDEL_CB))->GetCheck() == 1) ? TRUE : FALSE;
GetDlgItem(IDC_REGDEL_BTN)->EnableWindow(enable);
}
BOOL COptionsSystem::OnInitDialog()
{
BOOL bResult = CPropertyPage::OnInitDialog();
bool bofferdeleteregistry =
PWSprefs::GetInstance()->OfferDeleteRegistry();
if (!bofferdeleteregistry) {
GetDlgItem(IDC_REGDEL_GRP)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_REGDEL_CB)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_REGDEL_BTN)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_REGDEL_CB)->EnableWindow(FALSE);
}
GetDlgItem(IDC_REGDEL_BTN)->EnableWindow(FALSE);
CSpinButtonCtrl* pspin = (CSpinButtonCtrl *)GetDlgItem(IDC_RESPIN);
pspin->SetBuddy(GetDlgItem(IDC_MAXREITEMS));
pspin->SetRange(0, ID_TRAYRECENT_ENTRYMAX - ID_TRAYRECENT_ENTRY1 + 1);
pspin->SetBase(10);
pspin->SetPos(m_maxreitems);
pspin = (CSpinButtonCtrl *)GetDlgItem(IDC_MRUSPIN);
pspin->SetBuddy(GetDlgItem(IDC_MAXMRUITEMS));
pspin->SetRange(0, ID_FILE_MRU_ENTRYMAX - ID_FILE_MRU_ENTRY1 + 1);
pspin->SetBase(10);
pspin->SetPos(m_maxmruitems);
OnUseSystemTray();
// 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 bResult;
}
// Activate the tooltip control.
m_ToolTipCtrl->Activate(TRUE);
m_ToolTipCtrl->SetMaxTipWidth(300);
// Double time to allow reading by user - there is a lot there!
int iTime = m_ToolTipCtrl->GetDelayTime(TTDT_AUTOPOP);
m_ToolTipCtrl->SetDelayTime(TTDT_AUTOPOP, 2 * iTime);
if (m_ToolTipCtrl != NULL) {
CString cs_ToolTip(MAKEINTRESOURCE(IDS_REGDEL_CB));
m_ToolTipCtrl->AddTool(GetDlgItem(IDC_REGDEL_CB), cs_ToolTip);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void COptionsSystem::OnApplyRegistryDeleteNow()
{
UpdateData(TRUE);
if (m_deleteregistry == TRUE) {
if (AfxMessageBox(IDS_CONFIRMDELETEREG, MB_YESNO | MB_ICONSTOP) == IDYES)
PWSprefs::GetInstance()->DeleteRegistryEntries();
}
GetDlgItem(IDC_REGDEL_BTN)->EnableWindow(FALSE);
UpdateData(FALSE);
}
BOOL COptionsSystem::OnKillActive()
{
// Needed as we have DDV routines.
return CPropertyPage::OnKillActive();
}
// Override PreTranslateMessage() so RelayEvent() can be
// called to pass a mouse message to CPWSOptions's
// tooltip control for processing.
BOOL COptionsSystem::PreTranslateMessage(MSG* pMsg)
{
if (m_ToolTipCtrl != NULL)
m_ToolTipCtrl->RelayEvent(pMsg);
return CPropertyPage::PreTranslateMessage(pMsg);
}