📄 mypropertypage1.cpp
字号:
// MyPropertyPage1.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "..\HookShr\ComDef.h"
#include "FileGuard.h"
#include "FGDevice.h"
#include "FileGuardApp.h"
#include "MyPropertyPage1.h"
#include "IniFile.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CFileGuardPropertyPage1, CPropertyPage)
IMPLEMENT_DYNCREATE(CFileGuardPropertyPage2, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
// CFileGuardPropertyPage1 property page
CFileGuardPropertyPage1::CFileGuardPropertyPage1() : CPropertyPage(CFileGuardPropertyPage1::IDD)
{
//{{AFX_DATA_INIT(CFileGuardPropertyPage1)
m_strPath = _T("");
m_nAction = -1;
m_strHookStatus = _T("");
m_bActivate = FALSE;
m_bWriteProtection = FALSE;
m_bReadProtection = FALSE;
m_bHideFile = FALSE;
m_bDeleteProtection = FALSE;
//}}AFX_DATA_INIT
}
CFileGuardPropertyPage1::~CFileGuardPropertyPage1()
{
}
void CFileGuardPropertyPage1::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFileGuardPropertyPage1)
DDX_Text(pDX, IDC_PATH, m_strPath);
DDX_Radio(pDX, IDC_REMOVE, m_nAction);
DDX_Text(pDX, IDC_HOOK_STATUS, m_strHookStatus);
DDX_Check(pDX, IDC_ACTIVATEPROTECTION, m_bActivate);
DDX_Check(pDX, IDC_PROTECTWRITE, m_bWriteProtection);
DDX_Check(pDX, IDC_PROTECTREAD, m_bReadProtection);
DDX_Check(pDX, IDC_HIDE, m_bHideFile);
DDX_Check(pDX, IDC_PROTECTDELETE, m_bDeleteProtection);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFileGuardPropertyPage1, CPropertyPage)
//{{AFX_MSG_MAP(CFileGuardPropertyPage1)
ON_BN_CLICKED(IDC_ADD, OnAdd)
ON_BN_CLICKED(IDC_REMOVE, OnRemove)
ON_EN_CHANGE(IDC_PATH, OnChangePath)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFileGuardPropertyPage2 property page
CFileGuardPropertyPage2::CFileGuardPropertyPage2() : CPropertyPage(CFileGuardPropertyPage2::IDD)
{
//{{AFX_DATA_INIT(CFileGuardPropertyPage2)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CFileGuardPropertyPage2::~CFileGuardPropertyPage2()
{
}
void CFileGuardPropertyPage2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFileGuardPropertyPage2)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFileGuardPropertyPage2, CPropertyPage)
//{{AFX_MSG_MAP(CFileGuardPropertyPage2)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CFileGuardPropertyPage1::OnAdd()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_PROTECTDELETE)->EnableWindow(TRUE);
GetDlgItem(IDC_PROTECTWRITE)->EnableWindow(TRUE);
GetDlgItem(IDC_PROTECTREAD)->EnableWindow(TRUE);
GetDlgItem(IDC_HIDE)->EnableWindow(TRUE);
}
void CFileGuardPropertyPage1::OnRemove()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_PROTECTDELETE)->EnableWindow(FALSE);
GetDlgItem(IDC_PROTECTWRITE)->EnableWindow(FALSE);
GetDlgItem(IDC_PROTECTREAD)->EnableWindow(FALSE);
GetDlgItem(IDC_HIDE)->EnableWindow(FALSE);
}
BOOL CFileGuardPropertyPage1::OnInitDialog()
{
CPropertyPage::OnInitDialog();
//Set hook status:
if(hPrevInstanceWnd==NULL || !::SendMessage(hPrevInstanceWnd, WM_QUERY_PROTECTION, 0, 0))
m_strHookStatus.LoadString(IDS_IND_STOP);
else
{
GetDlgItem(IDC_ACTIVATEPROTECTION)->EnableWindow(FALSE);
m_strHookStatus.LoadString(IDS_IND_ACTIVATE);
}
m_nAction=1; //check "add" button.
UpdateData(FALSE);
OnAdd();
OnChangePath();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFileGuardPropertyPage1::OnChangePath()
{
//set radio button (IDC_ADD) text:
FILE_NODE *pFN;
UpdateData();
CString strPath=m_strPath;
FGFormatPath(strPath, FALSE);
if((pFN=protFileList.IsInList(strPath))!=NULL)
{
SetDlgItemText(IDC_ADD, "已保护 ");
GetDlgItem(IDC_REMOVE)->EnableWindow(TRUE);
m_protectionType=pFN->protFile.PF_type;
}
else
{
SetDlgItemText(IDC_ADD, "保护 ");
m_nAction=1; //check "add" button.
OnAdd();
GetDlgItem(IDC_REMOVE)->EnableWindow(FALSE);
m_protectionType=defProtectionType;
}
m_bDeleteProtection=((m_protectionType & PT_DELETE)==PT_DELETE);
m_bWriteProtection=((m_protectionType & PT_WRITE)==PT_WRITE);
m_bReadProtection=((m_protectionType & PT_READ)==PT_READ);
m_bHideFile=((m_protectionType & PT_HIDE)==PT_HIDE);
UpdateData(FALSE);
}
void CFileGuardPropertyPage1::OnOK()
{
if(m_nAction==1) //add path.
m_protectionType=(PT_DELETE * m_bDeleteProtection) | (PT_WRITE * m_bWriteProtection) | (PT_READ * m_bReadProtection) | (PT_HIDE * m_bHideFile);
else m_protectionType=0;
CPropertyPage::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -