📄 cdipage.cpp
字号:
// DIPage.cpp : implementation file
//
#include "stdafx.h"
#include "CDIPage.h"
#include "Common/Useful.h"
#include "Common/DirDialog.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CDIPage1, CPropertyPage)
IMPLEMENT_DYNCREATE(CDIPage2, CPropertyPage)
IMPLEMENT_DYNCREATE(CDIPage3, CPropertyPage)
IMPLEMENT_DYNCREATE(CDIPage4, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
// CDIPage1 property page
CDIPage1::CDIPage1() : CPropertyPage(CDIPage1::IDD)
{
//{{AFX_DATA_INIT(CDIPage1)
m_bRemovable = FALSE;
m_bRemote = FALSE;
m_bRamDrive = FALSE;
m_nInterval = 0;
m_bCDROM = FALSE;
m_bFixed = FALSE;
m_strExclude = _T("");
//}}AFX_DATA_INIT
}
CDIPage1::~CDIPage1()
{
}
void CDIPage1::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDIPage1)
DDX_Control(pDX, IDC_SPIN_INTERVAL, m_wndIntervalSpin);
DDX_Check(pDX, IDC_REMOVABLE, m_bRemovable);
DDX_Check(pDX, IDC_REMOTE, m_bRemote);
DDX_Check(pDX, IDC_RAMDRIVE, m_bRamDrive);
DDX_Text(pDX, IDC_INTERVAL, m_nInterval);
DDX_Check(pDX, IDC_CDROM, m_bCDROM);
DDX_Check(pDX, IDC_FIXED, m_bFixed);
DDX_Text(pDX, IDC_EXCLUDE, m_strExclude);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDIPage1, CPropertyPage)
//{{AFX_MSG_MAP(CDIPage1)
ON_BN_CLICKED(IDC_CDROM, OnChangde)
ON_EN_CHANGE(IDC_EXCLUDE, OnChangde)
ON_BN_CLICKED(IDC_FIXED, OnChangde)
ON_EN_CHANGE(IDC_INTERVAL, OnChangde)
ON_BN_CLICKED(IDC_RAMDRIVE, OnChangde)
ON_BN_CLICKED(IDC_REMOTE, OnChangde)
ON_BN_CLICKED(IDC_REMOVABLE, OnChangde)
//ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_INTERVAL, OnChangde)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDIPage2 property page
CDIPage2::CDIPage2() : CPropertyPage(CDIPage2::IDD)
{
//{{AFX_DATA_INIT(CDIPage2)
m_bEnableFolder = FALSE;
m_dRedAlert = 0.0;
m_dYellowAlert = 0.0;
//}}AFX_DATA_INIT
}
CDIPage2::~CDIPage2()
{
}
void CDIPage2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDIPage2)
DDX_Control(pDX, IDC_DI_FOLDER_LIST, m_wndFolderList);
DDX_Control(pDX, IDC_REMOVE_FOLDER, m_wndFolderRemove);
DDX_Control(pDX, IDC_ADD_FOLDER, m_wndFolderAdd);
DDX_Control(pDX, IDC_FOLDER_UP, m_wndFolderUp);
DDX_Control(pDX, IDC_FOLDER_DOWN, m_wndFolderDown);
DDX_Check(pDX, IDC_ENABLE_FOLDER, m_bEnableFolder);
DDX_Text(pDX, IDC_RED_ALERT, m_dRedAlert);
DDX_Text(pDX, IDC_YELLOW_ALERT, m_dYellowAlert);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDIPage2, CPropertyPage)
//{{AFX_MSG_MAP(CDIPage2)
ON_BN_CLICKED(IDC_ENABLE_FOLDER, OnEnableFolder)
ON_EN_CHANGE(IDC_RED_ALERT, OnChangde)
ON_EN_CHANGE(IDC_YELLOW_ALERT, OnChangde)
ON_BN_CLICKED(IDC_ADD_FOLDER, OnAddFolder)
ON_BN_CLICKED(IDC_REMOVE_FOLDER, OnRemoveFolder)
ON_BN_CLICKED(IDC_FOLDER_UP, OnFolderUp)
ON_BN_CLICKED(IDC_FOLDER_DOWN, OnFolderDown)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDIPage3 property page
CDIPage3::CDIPage3() : CPropertyPage(CDIPage3::IDD)
{
//{{AFX_DATA_INIT(CDIPage3)
m_bEnableBackground = FALSE;
m_strBmpDrive = _T("");
m_strBmpFolder = _T("");
m_strBmpFree = _T("");
m_strBmpHigh = _T("");
m_strBmpPressed = _T("");
m_strBmpTotal = _T("");
//}}AFX_DATA_INIT
}
CDIPage3::~CDIPage3()
{
}
void CDIPage3::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDIPage3)
DDX_Control(pDX, IDC_BROWSE_PRESSED_BMP, m_wndBrowsePressed);
DDX_Control(pDX, IDC_BROWSE_TOTAL_BMP, m_wndBrowseTotal);
DDX_Control(pDX, IDC_BROWSE_HIGH_BMP, m_wndBrowseHigh);
DDX_Control(pDX, IDC_BROWSE_FREE_BMP, m_wndBrowseFree);
DDX_Control(pDX, IDC_BROWSE_FOLDER_BMP, m_wndBrowseFolder);
DDX_Control(pDX, IDC_BROWSE_DRIVE_BMP, m_wndBrowseDrive);
DDX_Check(pDX, IDC_BMP_BACKGROUND, m_bEnableBackground);
DDX_Text(pDX, IDC_DRIVE_BMP, m_strBmpDrive);
DDX_Text(pDX, IDC_FOLDER_BMP, m_strBmpFolder);
DDX_Text(pDX, IDC_FREE_BMP, m_strBmpFree);
DDX_Text(pDX, IDC_HIGH_BMP, m_strBmpHigh);
DDX_Text(pDX, IDC_PRESSED_BMP, m_strBmpPressed);
DDX_Text(pDX, IDC_TOTAL_BMP, m_strBmpTotal);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDIPage3, CPropertyPage)
//{{AFX_MSG_MAP(CDIPage3)
ON_BN_CLICKED(IDC_BMP_BACKGROUND, OnBmpBackground)
ON_EN_CHANGE(IDC_DRIVE_BMP, OnChanged)
ON_EN_CHANGE(IDC_FOLDER_BMP, OnChanged)
ON_EN_CHANGE(IDC_FREE_BMP, OnChanged)
ON_EN_CHANGE(IDC_HIGH_BMP, OnChanged)
ON_EN_CHANGE(IDC_PRESSED_BMP, OnChanged)
ON_EN_CHANGE(IDC_TOTAL_BMP, OnChanged)
//}}AFX_MSG_MAP
ON_COMMAND_RANGE(IDC_BROWSE_DRIVE_BMP, IDC_BROWSE_PRESSED_BMP, OnBrowse)
END_MESSAGE_MAP()
CDIPage4::CDIPage4() : CPropertyPage(CDIPage4::IDD)
{
//{{AFX_DATA_INIT(CDIPage4)
m_nStartMode = 0;
m_intDetailStartup = 0;
//}}AFX_DATA_INIT
}
CDIPage4::~CDIPage4()
{
}
void CDIPage4::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDIPage4)
DDX_CBIndex(pDX, IDC_STARTUP_COMBO, m_nStartMode);
DDX_CBIndex(pDX, IDC_DETAIL_STARTUP, m_intDetailStartup);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDIPage4, CPropertyPage)
//{{AFX_MSG_MAP(CDIPage4)
ON_CBN_SELCHANGE(IDC_STARTUP_COMBO, OnSelChanged)
ON_CBN_SELCHANGE(IDC_DETAIL_STARTUP, OnSelChanged)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDIPage2 property page
void CDIPage3::OnBmpBackground()
{
UpdateData();
SetModified();
EnableControls(m_bEnableBackground);
}
void CDIPage3::EnableControls(BOOL b)
{
m_wndBrowsePressed.EnableWindow(b);
m_wndBrowseTotal.EnableWindow(b);
m_wndBrowseHigh.EnableWindow(b);
m_wndBrowseFree.EnableWindow(b);
m_wndBrowseFolder.EnableWindow(b);
m_wndBrowseDrive.EnableWindow(b);
GetDlgItem(IDC_DRIVE_BMP)->EnableWindow(b);
GetDlgItem(IDC_FOLDER_BMP)->EnableWindow(b);
GetDlgItem(IDC_TOTAL_BMP)->EnableWindow(b);
GetDlgItem(IDC_FREE_BMP)->EnableWindow(b);
GetDlgItem(IDC_HIGH_BMP)->EnableWindow(b);
GetDlgItem(IDC_PRESSED_BMP)->EnableWindow(b);
}
BOOL CDIPage3::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CWinApp* app = AfxGetApp();
CString strPath = GetHomeDirectory();
m_bEnableBackground = app->GetProfileInt("Settings", "EnableBackground", 1);
m_strBmpDrive = app->GetProfileString("Settings", "BmpDrive", strPath+"images\\Drive.bmp");
m_strBmpFolder = app->GetProfileString("Settings", "BmpFolder", strPath+"images\\Folder.bmp");
m_strBmpFree = app->GetProfileString("Settings", "BmpFree", strPath+"images\\Free.bmp");
m_strBmpHigh = app->GetProfileString("Settings", "BmpHigh", strPath+"images\\High.bmp");
m_strBmpPressed = app->GetProfileString("Settings", "BmpPressed", strPath+"images\\Pressed.bmp");
m_strBmpTotal = app->GetProfileString("Settings", "BmpTotal", strPath+"images\\Total.bmp");
UpdateData(FALSE);
EnableControls(m_bEnableBackground);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDIPage3::Apply()
{
if (!IsWindow(GetSafeHwnd()))
return;
UpdateData();
CWinApp* app = AfxGetApp();
app->WriteProfileInt("Settings", "EnableBackground", m_bEnableBackground);
app->WriteProfileString("Settings", "BmpDrive", m_strBmpDrive);
app->WriteProfileString("Settings", "BmpFolder", m_strBmpFolder);
app->WriteProfileString("Settings", "BmpFree", m_strBmpFree);
app->WriteProfileString("Settings", "BmpHigh", m_strBmpHigh);
app->WriteProfileString("Settings", "BmpPressed", m_strBmpPressed);
app->WriteProfileString("Settings", "BmpTotal", m_strBmpTotal);
}
void CDIPage2::Apply()
{
if (!IsWindow(GetSafeHwnd()))
return;
UpdateData();
CWinApp* app = AfxGetApp();
CString strData;
app->WriteProfileInt("Settings", "EnableFolder", m_bEnableFolder);
strData.Format("%f", m_dRedAlert);
app->WriteProfileString("Settings", "RedAlert", strData);
strData.Format("%f", m_dYellowAlert);
app->WriteProfileString("Settings", "YellowAlert", strData);
// Save Folder data
CString str;
int n = 0;
int nCount = m_wndFolderList.GetCount();
for (n=0; n<nCount; n++)
{
str.Format("FolderData%d", n);
m_wndFolderList.GetText(n, strData);
app->WriteProfileString("Settings", str, strData);
}
//remove other lists
n = nCount;
str.Format("FolderData%d", n);
strData = app->GetProfileString("Settings", str, "");
while (!strData.IsEmpty())
{
app->WriteProfileString("Settings", str, "");
n++;
str.Format("FolderData%d", n);
strData = app->GetProfileString("Settings", str, "");
}
}
void CDIPage1::Apply()
{
if (!IsWindow(GetSafeHwnd()))
return;
UpdateData();
CWinApp* app = AfxGetApp();
app->WriteProfileInt("Settings", "EnableRemovable", m_bRemovable);
app->WriteProfileInt("Settings", "EnableFixed", m_bFixed);
app->WriteProfileInt("Settings", "EnableCDROM", m_bCDROM);
app->WriteProfileInt("Settings", "EnableRemote", m_bRemote);
app->WriteProfileInt("Settings", "EnableRAMDisk", m_bRamDrive);
app->WriteProfileInt("Settings", "Interval", m_nInterval);
app->WriteProfileString("Settings", "Exclude", m_strExclude);
}
void CDIPage4::Apply()
{
if (!IsWindow(GetSafeHwnd()))
return;
UpdateData();
CWinApp* app = AfxGetApp();
app->WriteProfileInt("Settings", "StartUpMode", m_nStartMode);
app->WriteProfileInt("Settings", "DetailStartUpMode", m_intDetailStartup);
}
void CDIPage3::OnBrowse(UINT nID)
{
CString str;
str.LoadString(IDS_BMP_FILTER);
CString strFile;
GetDlgItem(nID+10)->GetWindowText(strFile);
CFileDialog dlg(TRUE, "bmp", strFile, OFN_FILEMUSTEXIST |
OFN_HIDEREADONLY,str,this);
if (dlg.DoModal() == IDOK)
{
GetDlgItem(nID+10)->SetWindowText(dlg.GetPathName());
UpdateData();
SetModified();
}
}
void CDIPage3::OnChanged()
{
SetModified();
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void CDIPage1::OnChangde()
{
SetModified();
}
BOOL CDIPage1::OnInitDialog()
{
CPropertyPage::OnInitDialog();
m_wndIntervalSpin.SetRange (1,999);
CWinApp* app = AfxGetApp();
// LoadSettings
m_bRemovable= app->GetProfileInt("Settings", "EnableRemovable", 1);
m_bFixed = app->GetProfileInt("Settings", "EnableFixed", 1);
m_bCDROM = app->GetProfileInt("Settings", "EnableCDROM", 1);
m_bRemote = app->GetProfileInt("Settings", "EnableRemote", 0);
m_bRamDrive = app->GetProfileInt("Settings", "EnableRAMDisk", 0);
m_nInterval = app->GetProfileInt("Settings", "Interval", 3);
m_strExclude = app->GetProfileString("Settings", "Exclude", "A:\\ B:\\");
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDIPage2::OnEnableFolder()
{
UpdateData();
SetModified();
EnableControls(m_bEnableFolder);
}
void CDIPage2::OnChangde()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CPropertyPage::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
SetModified();
}
void CDIPage2::EnableControls(BOOL b)
{
m_wndFolderRemove.EnableWindow(b);
m_wndFolderAdd.EnableWindow(b);
m_wndFolderUp.EnableWindow(b);
m_wndFolderDown.EnableWindow(b);
GetDlgItem(IDC_YELLOW_ALERT)->EnableWindow(b);
GetDlgItem(IDC_RED_ALERT)->EnableWindow(b);
GetDlgItem(IDC_DI_FOLDER_LIST)->EnableWindow(b);
}
BOOL CDIPage2::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CWinApp* app = AfxGetApp();
CString strData;
m_bEnableFolder = app->GetProfileInt("Settings", "EnableFolder", 1);
strData = app->GetProfileString("Settings", "RedAlert", "50.5");
m_dRedAlert = atof(strData);
strData = app->GetProfileString("Settings", "YellowAlert", "30.5");
m_dYellowAlert = atof(strData);
// Load Folder data
CString str;
int n = 0;
str.Format("FolderData%d", n);
strData = app->GetProfileString("Settings", str, "");
while (!strData.IsEmpty())
{
m_wndFolderList.AddString(strData);
n++;
str.Format("FolderData%d", n);
strData = app->GetProfileString("Settings", str, "");
}
m_wndFolderList.SetCurSel(0);
UpdateData(FALSE);
EnableControls(m_bEnableFolder);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDIPage2::OnAddFolder()
{
CDirDialog dlg;
CString str;
str.LoadString(IDS_SELECTFOLDER_TO_MONITOR);
dlg.m_strTitle = str;
int i = m_wndFolderList.GetCurSel();
if (i != -1)
m_wndFolderList.GetText(i, dlg.m_strSelDir);
if (dlg.DoBrowse() == IDOK)
{
i = m_wndFolderList.AddString(dlg.m_strPath);
m_wndFolderList.SetCurSel(i);
}
}
void CDIPage2::OnRemoveFolder()
{
int i = m_wndFolderList.GetCurSel();
if (i == -1)
{
MessageBeep(0xFFFFFFFF);
return;
}
m_wndFolderList.DeleteString(i);
if (i-1 >= 0)
m_wndFolderList.SetCurSel(i-1);
else if (i < m_wndFolderList.GetCount())
m_wndFolderList.SetCurSel(i);
}
void CDIPage2::OnFolderUp()
{
int i = m_wndFolderList.GetCurSel();
if (i == -1 || i == 0)
{
MessageBeep(0xFFFFFFFF);
return;
}
CString str;
m_wndFolderList.GetText(i, str);
m_wndFolderList.DeleteString(i);
m_wndFolderList.InsertString(i-1, str);
m_wndFolderList.SetCurSel(i-1);
}
void CDIPage2::OnFolderDown()
{
int i = m_wndFolderList.GetCurSel();
int nCount = m_wndFolderList.GetCount();
if (i == -1 || i == nCount-1)
{
MessageBeep(0xFFFFFFFF);
return;
}
CString str;
m_wndFolderList.GetText(i, str);
m_wndFolderList.DeleteString(i);
m_wndFolderList.InsertString(i+1, str);
m_wndFolderList.SetCurSel(i+1);
}
BOOL CDIPage4::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CWinApp* app = AfxGetApp();
m_nStartMode = app->GetProfileInt("Settings", "StartUpMode", 0);
m_intDetailStartup = app->GetProfileInt("Settings", "DetailStartUpMode", 0);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDIPage4::OnSelChanged()
{
SetModified();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -