⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 optionsdialog.cpp

📁 监控文件目录的VC程序
💻 CPP
字号:
// OptionsDialog.cpp : implementation file
//

#include "stdafx.h"
#include "dwatch.h"
#include "OptionsDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog dialog

/////////////////////////////////////////////////////////////////////////////
// Helper Funcs

/////////////////////////////////////////////////////////////////////////////

COptionsDialog::COptionsDialog(CWnd* pParent /*=NULL*/)
	: CDialog(COptionsDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(COptionsDialog)
	m_dirname = _T("C:\\");
	m_access = TRUE;
	m_attributes = TRUE;
	m_dirnames = TRUE;
	m_filenames = TRUE;
	m_security = TRUE;
	m_size = TRUE;
	m_tstamp = TRUE;
	m_write = TRUE;
	//}}AFX_DATA_INIT
}


void COptionsDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(COptionsDialog)
	DDX_Text(pDX, IDC_EDIT_DIRECTORY, m_dirname);
	DDX_Check(pDX, IDC_CHECK_ACCESS, m_access);
	DDX_Check(pDX, IDC_CHECK_ATTRIBUTES, m_attributes);
	DDX_Check(pDX, IDC_CHECK_DIRNAMES, m_dirnames);
	DDX_Check(pDX, IDC_CHECK_FILENAMES, m_filenames);
	DDX_Check(pDX, IDC_CHECK_SECURITY, m_security);
	DDX_Check(pDX, IDC_CHECK_SIZE, m_size);
	DDX_Check(pDX, IDC_CHECK_TSTAMP, m_tstamp);
	DDX_Check(pDX, IDC_CHECK_WRITES, m_write);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(COptionsDialog, CDialog)
	//{{AFX_MSG_MAP(COptionsDialog)
	ON_BN_CLICKED(IDC_BUTTON_GO, OnButtonGo)
	ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
	ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear)
	ON_BN_CLICKED(IDC_BUTTON_CANCEL, OnButtonCancel)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
	ON_BN_CLICKED(IDC_BUTTON_ABOUT, OnButtonAbout)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COptionsDialog message handlers

void COptionsDialog::OnButtonGo() 
{
	UpdateData (TRUE);
	if (m_dirname[m_dirname.GetLength()-1] != '\\')
		m_dirname += '\\';
	DWORD attributes = GetFileAttributes(m_dirname);
	if (attributes != 0xffffffff && (attributes & FILE_ATTRIBUTE_DIRECTORY))
		EndDialog (0);
	else
	{
		CString cs = m_dirname + "\nis not a valid directory";
		MessageBox (cs, "Error", MB_ICONSTOP);
		return;
	}
}

void COptionsDialog::OnButtonStop() 
{
	UpdateData (TRUE);
	EndDialog (1);
}


void COptionsDialog::OnButtonClear() 
{
	EndDialog (2);	
}

void COptionsDialog::OnButtonCancel() 
{
	EndDialog (-1);
}

void COptionsDialog::OnButtonSave() 
{
	EndDialog (3);
}

void COptionsDialog::OnButtonAbout() 
{
	ShellAbout (GetSafeHwnd(), "Directory Watchdog", "Author: Peter Seliger - pittbull_nt@yahoo.com", NULL); 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -