www.pudn.com > FileGuard.zip > ProgPropertyPage1.cpp


// ProgPropertyPage1.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "resource.h" 
#include "..\HookShr\HookError.h" 
#include "FileGuard.h" 
#include "FGDevice.h" 
#include "FileGuardApp.h" 
#include "MainFrm.h" 
#include "ProgPropertyPage1.h" 
#include "MyPropertyPage1.h" 
 
#ifdef _DEBUG 
#undef THIS_FILE 
static char BASED_CODE THIS_FILE[] = __FILE__; 
#endif 
 
IMPLEMENT_DYNCREATE(CProgPropPage, CPropertyPage) 
IMPLEMENT_DYNCREATE(CDefPropPage, CPropertyPage) 
IMPLEMENT_DYNCREATE(CProtPropPage, CPropertyPage) 
 
///////////////////////////////////////////////////////////////////////////// 
// CProgPropPage property page 
 
CProgPropPage::CProgPropPage() : CPropertyPage(CProgPropPage::IDD) 
{ 
	//{{AFX_DATA_INIT(CProgPropPage) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
CProgPropPage::~CProgPropPage() 
{ 
} 
 
void CProgPropPage::DoDataExchange(CDataExchange* pDX) 
{ 
	CPropertyPage::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CProgPropPage) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CProgPropPage, CPropertyPage) 
	//{{AFX_MSG_MAP(CProgPropPage) 
	ON_BN_CLICKED(IDC_MINI_STATE, OnSecretProtection) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CDefPropPage property page 
 
CDefPropPage::CDefPropPage() : CPropertyPage(CDefPropPage::IDD) 
{ 
	//{{AFX_DATA_INIT(CDefPropPage) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
CDefPropPage::~CDefPropPage() 
{ 
} 
 
void CDefPropPage::DoDataExchange(CDataExchange* pDX) 
{ 
	CPropertyPage::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CDefPropPage) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CDefPropPage, CPropertyPage) 
	//{{AFX_MSG_MAP(CDefPropPage) 
	ON_BN_CLICKED(IDC_BROWSE, OnBrowse) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CProtPropPage property page 
 
CProtPropPage::CProtPropPage() : CPropertyPage(CProtPropPage::IDD) 
{ 
	//{{AFX_DATA_INIT(CProtPropPage) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
CProtPropPage::~CProtPropPage() 
{ 
} 
 
void CProtPropPage::DoDataExchange(CDataExchange* pDX) 
{ 
	CPropertyPage::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CProtPropPage) 
		// NOTE: the ClassWizard will add DDX and DDV calls here 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CProtPropPage, CPropertyPage) 
	//{{AFX_MSG_MAP(CProtPropPage) 
	ON_BN_CLICKED(IDC_PROT_SELF, OnProtectSelf) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
BOOL CProgPropPage::OnInitDialog()  
{ 
	CPropertyPage::OnInitDialog(); 
	 
	CheckDlgButton(IDC_ACTIVATE_ON_STARTUP, bActSysUp); 
	CheckDlgButton(IDC_ACTIVATE_ON_START, bActAppUp); 
	CheckDlgButton(IDC_MINI_STATE, bProtectSecretly); 
	CheckDlgButton(IDC_ADD_KEY, bRegKey); 
	CheckDlgButton(IDC_WARNING, bWarning); 
 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
BOOL CDefPropPage::OnInitDialog()  
{ 
	CPropertyPage::OnInitDialog(); 
	 
	CheckDlgButton(IDC_DELETE, (defProtectionType & PT_DELETE)==PT_DELETE); 
	CheckDlgButton(IDC_READ, (defProtectionType & PT_READ)==PT_READ); 
	CheckDlgButton(IDC_WRITE, (defProtectionType & PT_WRITE)==PT_WRITE); 
	CheckDlgButton(IDC_HIDE, (defProtectionType & PT_HIDE)==PT_HIDE); 
 
	SetDlgItemText(IDC_INI_PATH, lpszIniFilePath); 
 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void CDefPropPage::OnBrowse()  
{ 
	CFileDialog fileDlg(1); 
	 
	char lpszIniPath[MAX_PATH]; 
	GetDlgItemText(IDC_INI_PATH, lpszIniPath, MAX_PATH); 
	fileDlg.m_ofn.lpstrFile=lpszIniPath; 
	fileDlg.m_ofn.lpstrInitialDir=strInstallDir; 
	fileDlg.m_ofn.lpstrFilter="ini file (*.ini)\0*.ini\0all files (*.*)\0*.*\0"; 
	if(fileDlg.DoModal()==IDOK) 
		SetDlgItemText(IDC_INI_PATH, fileDlg.GetPathName()); 
} 
 
void CProgPropPage::OnOK()  
{ 
	bActSysUp=IsDlgButtonChecked(IDC_ACTIVATE_ON_STARTUP); 
	bActAppUp=IsDlgButtonChecked(IDC_ACTIVATE_ON_START); 
	bProtectSecretly=IsDlgButtonChecked(IDC_MINI_STATE); 
	bRegKey=IsDlgButtonChecked(IDC_ADD_KEY); 
	bWarning=IsDlgButtonChecked(IDC_WARNING); 
	 
	if(!bProtectSecretly || !hDevice) 
		((CMainFrame *)AfxGetMainWnd())->TaskBarAddIcon(); 
	else  
		((CMainFrame *)AfxGetMainWnd())->TaskBarDelIcon(); 
 
	if(!ModifyRegClsKey()) 
		ErrorHandler(FG_ERR_SET_REG_CLS_KEY_FAIL); 
	if(!ModifyRegSysStart()) 
		ErrorHandler(FG_ERR_SET_REG_SYS_START_FAIL); 
 
	CPropertyPage::OnOK(); 
} 
 
void CDefPropPage::OnOK()  
{ 
	defProtectionType=(IsDlgButtonChecked(IDC_DELETE) * PT_DELETE) | (IsDlgButtonChecked(IDC_READ) * PT_READ) 
		| (IsDlgButtonChecked(IDC_WRITE) * PT_WRITE) | (IsDlgButtonChecked(IDC_HIDE) * PT_HIDE); 
	 
	SaveProtectedFileInfo(&protFileList); 
	GetDlgItemText(IDC_INI_PATH, lpszIniFilePath, MAX_PATH); 
	((CMainFrame *)AfxGetMainWnd())->OnFlushProtFileInfo(); 
 
	CPropertyPage::OnOK(); 
} 
 
BOOL CProtPropPage::OnInitDialog() 
{ 
	CPropertyPage::OnInitDialog(); 
 
	CheckDlgButton(protFileList.bDelBak ? IDC_DEL_BAK: IDC_DEL_DENY, 1); 
	CheckDlgButton(protFileList.bWriteBak ? IDC_WRITE_BAK: IDC_WRITE_DENY, 1); 
	CheckDlgButton(IDC_PROT_SELF, bProtectSelf); 
 
	SetDlgItemInt(IDC_MAX_BAK_NUM, maxBakNum, FALSE); 
 
	return TRUE; 
} 
 
void CProtPropPage::OnOK() 
{ 
	protFileList.bDelBak=IsDlgButtonChecked(IDC_DEL_BAK); 
	protFileList.bWriteBak=IsDlgButtonChecked(IDC_WRITE_BAK); 
	bProtectSelf=IsDlgButtonChecked(IDC_PROT_SELF); 
 
	BOOL bSuccess; 
	maxBakNum=GetDlgItemInt(IDC_MAX_BAK_NUM, &bSuccess, FALSE); 
	if(!bSuccess || !maxBakNum) 
		maxBakNum=DEF_MAX_BAK_NUM; 
 
	if(hDevice) 
		if(!SendExtraInfo()) 
			ErrorHandler(FG_ERR_SEND_INFO_FAIL); 
 
	CPropertyPage::OnOK(); 
} 
 
void CProgPropPage::OnSecretProtection()  
{ 
	if(IsDlgButtonChecked(IDC_MINI_STATE)) 
		AfxMessageBox(IDS_PROG_WARN, MB_ICONINFORMATION); 
} 
 
void CProtPropPage::OnProtectSelf() 
{ 
	if(IsDlgButtonChecked(IDC_PROT_SELF)) 
		AfxMessageBox(IDS_ON_PROTECT_SELF, MB_ICONINFORMATION); 
}