📄 propertypage1.cpp
字号:
// PropertyPage1.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "Indent.h"
#include "MainFrm.h"
#include "PropertyPage1.h"
#include "IniFileReadWrite.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CPropertyPage1, CPropertyPage)
IMPLEMENT_DYNCREATE(CPropertyPage2, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
// CPropertyPage1 property page
CPropertyPage1::CPropertyPage1() : CPropertyPage(CPropertyPage1::IDD)
{
//{{AFX_DATA_INIT(CPropertyPage1)
m_SplashScreen = FALSE;
m_StatusBar = FALSE;
m_ToolBar = FALSE;
//}}AFX_DATA_INIT
}
CPropertyPage1::~CPropertyPage1()
{
}
void CPropertyPage1::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPropertyPage1)
DDX_Check(pDX, IDC_SPLASHSCREEN, m_SplashScreen);
DDX_Check(pDX, IDC_STATUSBAR, m_StatusBar);
DDX_Check(pDX, IDC_TOOLBAR, m_ToolBar);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPropertyPage1, CPropertyPage)
//{{AFX_MSG_MAP(CPropertyPage1)
ON_BN_CLICKED(IDC_SPLASHSCREEN, OnSplashscreen)
ON_BN_CLICKED(IDC_STATUSBAR, OnStatusbar)
ON_BN_CLICKED(IDC_TOOLBAR, OnToolbar)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropertyPage2 property page
CPropertyPage2::CPropertyPage2() : CPropertyPage(CPropertyPage2::IDD)
{
//{{AFX_DATA_INIT(CPropertyPage2)
//}}AFX_DATA_INIT
}
CPropertyPage2::~CPropertyPage2()
{
}
void CPropertyPage2::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPropertyPage2)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPropertyPage2, CPropertyPage)
//{{AFX_MSG_MAP(CPropertyPage2)
ON_BN_CLICKED(IDC_SELECTFILE, OnSelectfile)
ON_EN_CHANGE(IDC_EDIT_FILEPATHNAME, OnChangeEditFilepathname)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CPropertyPage1::OnSetActive()
{
CIniFileReadWrite IniValue(INIFILENAME);
if(IniValue.GetIntValue("SETUP","SplashScreen") == 1)
((CButton*)GetDlgItem(IDC_SPLASHSCREEN))->SetCheck(1);
if(IniValue.GetIntValue("SETUP","ToolBar") == 1)
((CButton*)GetDlgItem(IDC_TOOLBAR))->SetCheck(1);
if(IniValue.GetIntValue("SETUP","StatusBar") == 1)
((CButton*)GetDlgItem(IDC_STATUSBAR))->SetCheck(1);
return CPropertyPage::OnSetActive();
}
void CPropertyPage1::OnSplashscreen()
{
SetModified(TRUE);
}
void CPropertyPage1::OnStatusbar()
{
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
if(pMainFrame->m_wndStatusBar.IsWindowVisible())
{
pMainFrame->ShowControlBar(&pMainFrame->m_wndStatusBar,FALSE,FALSE);
((CMenu*)pMainFrame->GetMenu())->CheckMenuItem(ID_VIEW_STATUS_BAR,0);
}
else
{
pMainFrame->ShowControlBar(&pMainFrame->m_wndStatusBar,TRUE,FALSE);
((CMenu*)pMainFrame->GetMenu())->CheckMenuItem(ID_VIEW_STATUS_BAR,1);
}
SetModified(TRUE);
}
void CPropertyPage1::OnToolbar()
{
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
if(pMainFrame->m_wndToolBar.IsWindowVisible())
{
pMainFrame->ShowControlBar(&pMainFrame->m_wndToolBar,FALSE,FALSE);
((CMenu*)pMainFrame->GetMenu())->CheckMenuItem(ID_VIEW_TOOLBAR,0);
}
else
{
pMainFrame->ShowControlBar(&pMainFrame->m_wndToolBar,TRUE,FALSE);
((CMenu*)pMainFrame->GetMenu())->CheckMenuItem(ID_VIEW_TOOLBAR,1);
}
SetModified(TRUE);
}
BOOL CPropertyPage1::OnApply()
{
CString strTemp;
strTemp.Format("%d",m_SplashScreen);
CIniFileReadWrite IniValue(INIFILENAME);
IniValue.WriteStringValue("SETUP","SplashScreen",strTemp);
strTemp.Format("%d",m_ToolBar);
IniValue.WriteStringValue("SETUP","ToolBar",strTemp);
strTemp.Format("%d",m_StatusBar);
IniValue.WriteStringValue("SETUP","StatusBar",strTemp);
SetModified(FALSE);
return TRUE;
// return CPropertyPage::OnApply();
}
void CPropertyPage2::OnSelectfile()
{
char szFilters[] = "Access files(*.mdb)|*.mdb|All Files (*.*)|*.*||";
CFileDialog FileDlg(TRUE,NULL,NULL,
OFN_EXPLORER | OFN_FILEMUSTEXIST| OFN_HIDEREADONLY,szFilters,this);
CString strOrigin, strCurrent;
// Get application current directory
CString strTemp;
char PathBuffer[255];
GetModuleFileName(AfxGetInstanceHandle(),PathBuffer,255);
strTemp.Format("%s",PathBuffer);
strOrigin = strTemp.Mid(0,strTemp.ReverseFind('\\'));
if(FileDlg.DoModal() == IDOK)
{
GetCurrentDirectory(MAX_PATH,strCurrent.GetBuffer(MAX_PATH));
strCurrent.ReleaseBuffer();
if(strOrigin.Compare(strCurrent) == 0)
m_strFilePath = FileDlg.GetFileName();
else
m_strFilePath = FileDlg.GetPathName();
((CEdit*)GetDlgItem(IDC_EDIT_FILEPATHNAME))->SetWindowText(m_strFilePath);
}
}
BOOL CPropertyPage2::OnApply()
{
UpdateData();
CIniFileReadWrite IniValue(INIFILENAME);
IniValue.WriteStringValue("DATABASE","DataBaseFile",m_strFilePath);
SetModified(FALSE);
return TRUE;
// return CPropertyPage::OnApply();
}
void CPropertyPage2::OnChangeEditFilepathname()
{
SetModified(TRUE);
}
BOOL CPropertyPage2::OnSetActive()
{
CIniFileReadWrite IniValue(INIFILENAME);
m_strFilePath = IniValue.GetStringValue("DATABASE","DataBaseFile");
((CEdit*)GetDlgItem(IDC_EDIT_FILEPATHNAME))->SetWindowText(m_strFilePath);
SetModified(FALSE);
return CPropertyPage::OnSetActive();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -