Changeset 30
- Timestamp:
- 10/10/2007 10:36:05 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/PreferencesPage.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PreferencesPage.cpp
r28 r30 1 1 // PreferencesPage.cpp 2 // $Id$ 2 3 // 3 4 // Eraser. Secure data removal. For Windows. … … 47 48 , m_bResolveAskUser(TRUE) 48 49 { 49 //{{AFX_DATA_INIT(CEraserPreferencesPage)50 m_bClearSwap = FALSE;51 m_bShellextResults = FALSE;52 m_bResultsForFiles = FALSE;53 m_bResultsForUnusedSpace = FALSE;54 m_bResultsOnlyWhenFailed = FALSE;50 //{{AFX_DATA_INIT(CEraserPreferencesPage) 51 m_bClearSwap = FALSE; 52 m_bShellextResults = FALSE; 53 m_bResultsForFiles = FALSE; 54 m_bResultsForUnusedSpace = FALSE; 55 m_bResultsOnlyWhenFailed = FALSE; 55 56 m_bErasextEnabled = FALSE; 56 57 m_bEnableSlowPoll = FALSE; … … 85 86 86 87 BEGIN_MESSAGE_MAP(CEraserPreferencesPage, CPropertyPage) 87 //{{AFX_MSG_MAP(CEraserPreferencesPage)88 ON_BN_CLICKED(IDC_CHECK_RESULTS_FOR_UNUSED_SPACE, OnCheckResultsForUnusedSpace)89 ON_BN_CLICKED(IDC_CHECK_RESULTS_FOR_FILES, OnCheckResultsForFiles)90 //}}AFX_MSG_MAP88 //{{AFX_MSG_MAP(CEraserPreferencesPage) 89 ON_BN_CLICKED(IDC_CHECK_RESULTS_FOR_UNUSED_SPACE, OnCheckResultsForUnusedSpace) 90 ON_BN_CLICKED(IDC_CHECK_RESULTS_FOR_FILES, OnCheckResultsForFiles) 91 //}}AFX_MSG_MAP 91 92 ON_BN_CLICKED(IDC_BUTTON_PROTECTION, OnBnClickedButtonProtection) 92 93 ON_BN_CLICKED(IDC_BUTTON_HOTKEYS, OnBnClickedButtonHotkeys) … … 99 100 CSchedulerPreferencesPage::CSchedulerPreferencesPage() : CPropertyPage(CSchedulerPreferencesPage::IDD) 100 101 { 101 //{{AFX_DATA_INIT(CSchedulerPreferencesPage)102 m_bLog = FALSE;103 m_bStartup = FALSE;104 m_bNoVisualErrors = FALSE;105 m_bLogOnlyErrors = FALSE;106 m_dwMaxLogSize = 0;107 m_bNoTrayIcon = FALSE;108 m_bQueueTasks = FALSE;102 //{{AFX_DATA_INIT(CSchedulerPreferencesPage) 103 m_bLog = FALSE; 104 m_bStartup = FALSE; 105 m_bNoVisualErrors = FALSE; 106 m_bLogOnlyErrors = FALSE; 107 m_dwMaxLogSize = 0; 108 m_bNoTrayIcon = FALSE; 109 m_bQueueTasks = FALSE; 109 110 m_bEnabled = FALSE; 110 111 m_bHideOnMinimize = FALSE; … … 118 119 void CSchedulerPreferencesPage::DoDataExchange(CDataExchange* pDX) 119 120 { 120 CPropertyPage::DoDataExchange(pDX);121 //{{AFX_DATA_MAP(CSchedulerPreferencesPage)122 DDX_Control(pDX, IDC_SPIN_LIMIT, m_sbLimitSize);123 DDX_Check(pDX, IDC_CHECK_LOG, m_bLog);124 DDX_Check(pDX, IDC_CHECK_STARTUP, m_bStartup);125 DDX_Check(pDX, IDC_CHECK_NOVISUALERRORS, m_bNoVisualErrors);126 DDX_Check(pDX, IDC_CHECK_LOG_ONLYERRORS, m_bLogOnlyErrors);127 DDX_Text(pDX, IDC_EDIT_LIMIT, m_dwMaxLogSize);128 DDX_Check(pDX, IDC_CHECK_NOTRAYICON, m_bNoTrayIcon);129 DDX_Check(pDX, IDC_CHECK_QUEUE, m_bQueueTasks);121 CPropertyPage::DoDataExchange(pDX); 122 //{{AFX_DATA_MAP(CSchedulerPreferencesPage) 123 DDX_Control(pDX, IDC_SPIN_LIMIT, m_sbLimitSize); 124 DDX_Check(pDX, IDC_CHECK_LOG, m_bLog); 125 DDX_Check(pDX, IDC_CHECK_STARTUP, m_bStartup); 126 DDX_Check(pDX, IDC_CHECK_NOVISUALERRORS, m_bNoVisualErrors); 127 DDX_Check(pDX, IDC_CHECK_LOG_ONLYERRORS, m_bLogOnlyErrors); 128 DDX_Text(pDX, IDC_EDIT_LIMIT, m_dwMaxLogSize); 129 DDX_Check(pDX, IDC_CHECK_NOTRAYICON, m_bNoTrayIcon); 130 DDX_Check(pDX, IDC_CHECK_QUEUE, m_bQueueTasks); 130 131 DDX_Check(pDX, IDC_CHECK_ENABLE, m_bEnabled); 131 132 DDX_Check(pDX, IDC_CHECK_HIDEONMINIMIZE, m_bHideOnMinimize); … … 135 136 136 137 BEGIN_MESSAGE_MAP(CSchedulerPreferencesPage, CPropertyPage) 137 //{{AFX_MSG_MAP(CSchedulerPreferencesPage)138 ON_BN_CLICKED(IDC_CHECK_LOG_LIMITSIZE, OnCheckLogLimitsize)139 ON_BN_CLICKED(IDC_CHECK_LOG, OnCheckLog)138 //{{AFX_MSG_MAP(CSchedulerPreferencesPage) 139 ON_BN_CLICKED(IDC_CHECK_LOG_LIMITSIZE, OnCheckLogLimitsize) 140 ON_BN_CLICKED(IDC_CHECK_LOG, OnCheckLog) 140 141 ON_BN_CLICKED(IDC_CHECK_NOTRAYICON, OnCheckNotrayicon) 141 142 //}}AFX_MSG_MAP … … 145 146 static inline BOOL IsAdminOnNT() 146 147 { 147 SC_HANDLE hSC;148 149 // Try an Admin Privileged API - if it works return150 // TRUE - else FALSE151 152 hSC = OpenSCManager(NULL, NULL,153 GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE);154 155 if (hSC == NULL)156 return FALSE;157 158 CloseServiceHandle(hSC);159 return TRUE;148 SC_HANDLE hSC; 149 150 // Try an Admin Privileged API - if it works return 151 // TRUE - else FALSE 152 153 hSC = OpenSCManager(NULL, NULL, 154 GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE); 155 156 if (hSC == NULL) 157 return FALSE; 158 159 CloseServiceHandle(hSC); 160 return TRUE; 160 161 } 161 162 162 163 BOOL CEraserPreferencesPage::OnInitDialog() 163 164 { 164 CPropertyPage::OnInitDialog();165 166 // Clearing Paging file is a Windows NT security167 // feature and not available on Windows 9x168 169 OSVERSIONINFO ov;170 171 ZeroMemory(&ov, sizeof(OSVERSIONINFO));172 ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);173 174 VERIFY(GetVersionEx(&ov));175 176 CButton *pButtonSwap = (CButton*)GetDlgItem(IDC_CHECK_CLEAR_SWAP);177 178 if (ov.dwPlatformId == VER_PLATFORM_WIN32_NT)179 {180 if (IsAdminOnNT())181 {182 pButtonSwap->EnableWindow(TRUE);183 }184 }185 else186 {187 m_bClearSwap = FALSE;188 pButtonSwap->SetCheck(0);189 }190 191 192 BOOL bEnable = (m_bResultsForFiles || m_bResultsForUnusedSpace);193 194 GetDlgItem(IDC_CHECK_RESULTSONLYWHENFAILED)->EnableWindow(bEnable);195 GetDlgItem(IDC_CHECK_SHELLEXT_RESULTS)->EnableWindow(bEnable);196 165 CPropertyPage::OnInitDialog(); 166 167 // Clearing Paging file is a Windows NT security 168 // feature and not available on Windows 9x 169 170 OSVERSIONINFO ov; 171 172 ZeroMemory(&ov, sizeof(OSVERSIONINFO)); 173 ov.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 174 175 VERIFY(GetVersionEx(&ov)); 176 177 CButton *pButtonSwap = (CButton*)GetDlgItem(IDC_CHECK_CLEAR_SWAP); 178 179 if (ov.dwPlatformId == VER_PLATFORM_WIN32_NT) 180 { 181 if (IsAdminOnNT()) 182 { 183 pButtonSwap->EnableWindow(TRUE); 184 } 185 } 186 else 187 { 188 m_bClearSwap = FALSE; 189 pButtonSwap->SetCheck(0); 190 } 191 192 193 BOOL bEnable = (m_bResultsForFiles || m_bResultsForUnusedSpace); 194 195 GetDlgItem(IDC_CHECK_RESULTSONLYWHENFAILED)->EnableWindow(bEnable); 196 GetDlgItem(IDC_CHECK_SHELLEXT_RESULTS)->EnableWindow(bEnable); 197 197 198 198 199 CString strButtonTitle; … … 202 203 203 204 204 return TRUE; // return TRUE unless you set the focus to a control205 // EXCEPTION: OCX Property Pages should return FALSE205 return TRUE; // return TRUE unless you set the focus to a control 206 // EXCEPTION: OCX Property Pages should return FALSE 206 207 } 207 208 208 209 void CSchedulerPreferencesPage::OnCheckLogLimitsize() 209 210 { 210 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE));211 212 if (pCheck->GetCheck())213 {214 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(TRUE);215 m_sbLimitSize.EnableWindow(TRUE);216 }217 else218 {219 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(FALSE);220 m_sbLimitSize.EnableWindow(FALSE);221 }211 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE)); 212 213 if (pCheck->GetCheck()) 214 { 215 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(TRUE); 216 m_sbLimitSize.EnableWindow(TRUE); 217 } 218 else 219 { 220 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(FALSE); 221 m_sbLimitSize.EnableWindow(FALSE); 222 } 222 223 } 223 224 224 225 void CSchedulerPreferencesPage::OnCheckLog() 225 226 { 226 UpdateData(TRUE);227 GetDlgItem(IDC_CHECK_LOG_ONLYERRORS)->EnableWindow(m_bLog);228 229 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE));230 231 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(pCheck->GetCheck() && m_bLog);232 m_sbLimitSize.EnableWindow(pCheck->GetCheck() && m_bLog);233 234 pCheck->EnableWindow(m_bLog);235 GetDlgItem(IDC_STATIC_KB)->EnableWindow(m_bLog);227 UpdateData(TRUE); 228 GetDlgItem(IDC_CHECK_LOG_ONLYERRORS)->EnableWindow(m_bLog); 229 230 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE)); 231 232 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(pCheck->GetCheck() && m_bLog); 233 m_sbLimitSize.EnableWindow(pCheck->GetCheck() && m_bLog); 234 235 pCheck->EnableWindow(m_bLog); 236 GetDlgItem(IDC_STATIC_KB)->EnableWindow(m_bLog); 236 237 } 237 238 238 239 BOOL CSchedulerPreferencesPage::OnInitDialog() 239 240 { 240 CPropertyPage::OnInitDialog();241 242 GetDlgItem(IDC_CHECK_LOG_ONLYERRORS)->EnableWindow(m_bLog);243 244 m_sbLimitSize.SetBase(10);245 m_sbLimitSize.SetRange(1, 1024);246 m_sbLimitSize.SetPos(m_dwMaxLogSize);247 m_sbLimitSize.SetBuddy(GetDlgItem(IDC_EDIT_LIMIT));248 249 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE));250 251 if (m_dwMaxLogSize < 1)252 {253 m_dwMaxLogSize = 1;254 pCheck->SetCheck(0);255 }256 else257 {258 pCheck->SetCheck(1);259 }260 261 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(pCheck->GetCheck() && m_bLog);262 m_sbLimitSize.EnableWindow(pCheck->GetCheck() && m_bLog);263 264 pCheck->EnableWindow(m_bLog);265 GetDlgItem(IDC_STATIC_KB)->EnableWindow(m_bLog);266 267 if (m_bNoTrayIcon)268 {269 m_bHideOnMinimize = FALSE;270 GetDlgItem(IDC_CHECK_HIDEONMINIMIZE)->EnableWindow(FALSE);271 }272 273 274 275 276 UpdateData(FALSE);277 278 return TRUE; // return TRUE unless you set the focus to a control279 // EXCEPTION: OCX Property Pages should return FALSE241 CPropertyPage::OnInitDialog(); 242 243 GetDlgItem(IDC_CHECK_LOG_ONLYERRORS)->EnableWindow(m_bLog); 244 245 m_sbLimitSize.SetBase(10); 246 m_sbLimitSize.SetRange(1, 1024); 247 m_sbLimitSize.SetPos(m_dwMaxLogSize); 248 m_sbLimitSize.SetBuddy(GetDlgItem(IDC_EDIT_LIMIT)); 249 250 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE)); 251 252 if (m_dwMaxLogSize < 1) 253 { 254 m_dwMaxLogSize = 1; 255 pCheck->SetCheck(0); 256 } 257 else 258 { 259 pCheck->SetCheck(1); 260 } 261 262 GetDlgItem(IDC_EDIT_LIMIT)->EnableWindow(pCheck->GetCheck() && m_bLog); 263 m_sbLimitSize.EnableWindow(pCheck->GetCheck() && m_bLog); 264 265 pCheck->EnableWindow(m_bLog); 266 GetDlgItem(IDC_STATIC_KB)->EnableWindow(m_bLog); 267 268 if (m_bNoTrayIcon) 269 { 270 m_bHideOnMinimize = FALSE; 271 GetDlgItem(IDC_CHECK_HIDEONMINIMIZE)->EnableWindow(FALSE); 272 } 273 274 275 276 277 UpdateData(FALSE); 278 279 return TRUE; // return TRUE unless you set the focus to a control 280 // EXCEPTION: OCX Property Pages should return FALSE 280 281 } 281 282 282 283 void CSchedulerPreferencesPage::OnOK() 283 284 { 284 CPropertyPage::OnOK();285 286 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE));287 288 if (!pCheck->GetCheck())289 m_dwMaxLogSize = 0;285 CPropertyPage::OnOK(); 286 287 CButton *pCheck = static_cast<CButton*>(GetDlgItem(IDC_CHECK_LOG_LIMITSIZE)); 288 289 if (!pCheck->GetCheck()) 290 m_dwMaxLogSize = 0; 290 291 } 291 292 292 293 void CEraserPreferencesPage::OnCheckResultsForUnusedSpace() 293 294 { 294 UpdateData(TRUE);295 BOOL bEnable = (m_bResultsForFiles || m_bResultsForUnusedSpace);296 297 GetDlgItem(IDC_CHECK_RESULTSONLYWHENFAILED)->EnableWindow(bEnable);298 GetDlgItem(IDC_CHECK_SHELLEXT_RESULTS)->EnableWindow(bEnable);295 UpdateData(TRUE); 296 BOOL bEnable = (m_bResultsForFiles || m_bResultsForUnusedSpace); 297 298 GetDlgItem(IDC_CHECK_RESULTSONLYWHENFAILED)->EnableWindow(bEnable); 299 GetDlgItem(IDC_CHECK_SHELLEXT_RESULTS)->EnableWindow(bEnable); 299 300 if (!bEnable) 300 301 { … … 308 309 void CEraserPreferencesPage::OnCheckResultsForFiles() 309 310 { 310 UpdateData(TRUE);311 BOOL bEnable = (m_bResultsForFiles || m_bResultsForUnusedSpace);312 313 GetDlgItem(IDC_CHECK_RESULTSONLYWHENFAILED)->EnableWindow(bEnable);314 GetDlgItem(IDC_CHECK_SHELLEXT_RESULTS)->EnableWindow(bEnable);311 UpdateData(TRUE); 312 BOOL bEnable = (m_bResultsForFiles || m_bResultsForUnusedSpace); 313 314 GetDlgItem(IDC_CHECK_RESULTSONLYWHENFAILED)->EnableWindow(bEnable); 315 GetDlgItem(IDC_CHECK_SHELLEXT_RESULTS)->EnableWindow(bEnable); 315 316 if (!bEnable) 316 317 { … … 325 326 { 326 327 UpdateData(TRUE); 327 GetDlgItem(IDC_CHECK_HIDEONMINIMIZE)->EnableWindow(!m_bNoTrayIcon);328 GetDlgItem(IDC_CHECK_HIDEONMINIMIZE)->EnableWindow(!m_bNoTrayIcon); 328 329 } 329 330 … … 332 333 bool res; 333 334 CString strButtonTitle; 334 335 335 336 if (CSecurityManager::IsProtected()) 336 337 {
Note: See TracChangeset
for help on using the changeset viewer.
