📄 setupdlg.cpp
字号:
// SetupDlg.cpp : implementation file
//
#include "stdafx.h"
#include "12Clock.h"
#include "SetupDlg.h"
#include "registe.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetupDlg dialog
CSetupDlg::CSetupDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSetupDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetupDlg)
m_skinpath = _T("");
m_colorpath = _T("");
m_touming = 0;
m_slideredit = 0;
m_12hour = -1;
m_autorun = FALSE;
//}}AFX_DATA_INIT
}
void CSetupDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetupDlg)
DDX_Control(pDX, IDOK, m_ok);
DDX_Control(pDX, IDCANCEL, m_cancel);
DDX_Control(pDX, IDC_TOUMINGSLIDER, m_toumingslider);
DDX_Control(pDX, IDC_COLORCOMBO, m_colorcombo);
DDX_Control(pDX, IDC_SKINCOMBO, m_skincombo);
DDX_CBString(pDX, IDC_SKINCOMBO, m_skinpath);
DDX_CBString(pDX, IDC_COLORCOMBO, m_colorpath);
DDX_Slider(pDX, IDC_TOUMINGSLIDER, m_touming);
DDX_Text(pDX, IDC_SLIDEREDIT, m_slideredit);
DDX_Radio(pDX, IDC_12HOUR, m_12hour);
DDX_Check(pDX, IDC_AUTORUN, m_autorun);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetupDlg, CDialog)
//{{AFX_MSG_MAP(CSetupDlg)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_TOUMINGSLIDER, OnCustomdrawToumingslider)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetupDlg message handlers
BOOL CSetupDlg::OnInitDialog()
{
CDialog::OnInitDialog();
short shBtnColor = 30;
m_cancel.SetIcon(IDI_EXIT1,IDI_EXIT2);
m_cancel.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
m_cancel.SetAlign(CButtonST::ST_ALIGN_HORIZ);
m_cancel.DrawBorder(FALSE);
m_cancel.DrawTransparent(TRUE);
m_ok.SetIcon(IDI_APPLY1,IDI_APPLY2);
m_ok.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
m_ok.SetAlign(CButtonST::ST_ALIGN_HORIZ);
m_ok.DrawBorder(FALSE);
m_ok.DrawTransparent(TRUE);
m_toumingslider.SetTicFreq(10);
m_toumingslider.SetRange(0,100);
int nFilter;
TCHAR exeFullPath[MAX_PATH];
GetModuleFileName(NULL,exeFullPath,MAX_PATH);
strPath.Format("%s", exeFullPath);
strPath = strPath.Left(strPath.ReverseFind('\\'));
CString workpath;
char tmpstr[128];
char tmppath[128];
::GetCurrentDirectory(128,tmppath);
workpath=CString(tmppath)+CString("\\setup.ini");
::GetPrivateProfileString("ClockInfo","SkinPath","",tmpstr,128,workpath);
m_sFullSkinPath=tmpstr;
::GetPrivateProfileString("ClockInfo","NumPath","",tmpstr,128,workpath);
m_sFullNumPath=tmpstr;
::GetPrivateProfileString("ClockInfo","TouMingDu","80",tmpstr,128,workpath);
m_touming=atoi(tmpstr);
::GetPrivateProfileString("ClockInfo","24Hour","0",tmpstr,128,workpath);
m_12hour=atoi(tmpstr);
::GetPrivateProfileString("ClockInfo","AutoRun","0",tmpstr,128,workpath);
m_autorun=atoi(tmpstr);
nFilter=strPath.GetLength()+15;
CFileFind finder;
int m_skinint=0;
int m_numint=0;
int m_skintime=0;
int m_numtime=0;
// build a string with wildcards
CString strWildcard(strPath);
strWildcard += _T("\\skin\\*.bmp");
try
{
//--------------------------------------------------------------
// start working for filescount
//--------------------------------------------------------------
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if (finder.IsDots())
continue;
// if it's NOT a directory, recursively search it
if (!finder.IsDirectory())
{
if (finder.GetFilePath().GetLength() > nFilter)
{
//background
m_skincombo.AddString(finder.GetFileTitle());
m_skinpatharray.Add(finder.GetFilePath());
if(finder.GetFilePath()==m_sFullSkinPath)
{
m_skinint=m_skintime;
m_skinpath=finder.GetFileTitle();
}
else
m_skintime++;
}
else
{
//number
m_colorcombo.AddString(finder.GetFileTitle());
m_colorpatharray.Add(finder.GetFilePath());
if(finder.GetFilePath()==m_sFullNumPath)
{
m_numint=m_numtime;
m_colorpath=finder.GetFileTitle();
}
else
m_numint++;
}
}
}
}
catch(...)
{
}
m_skincombo.SetCurSel(m_skinint);
m_colorcombo.SetCurSel(m_numint);
m_toumingslider.SetPos(m_touming);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
CString CSetupDlg::GetSkinPath()
{
return m_sFullSkinPath;
}
CString CSetupDlg::GetColorPath()
{
return m_sFullNumPath;
}
int CSetupDlg::GetTouMingDu()
{
return m_touming;
}
void CSetupDlg::OnOK()
{
UpdateData();
m_sFullSkinPath=strPath+CString("\\skin\\")+m_skinpath+CString(".bmp");
m_sFullNumPath=strPath+CString("\\skin\\")+m_colorpath+CString(".bmp");
CString workpath;
char tmpstr[128];
char tmppath[128];
::GetCurrentDirectory(128,tmppath);
workpath=CString(tmppath)+CString("\\setup.ini");
::WritePrivateProfileString("ClockInfo","SkinPath",(LPCTSTR)m_sFullSkinPath,workpath);
::WritePrivateProfileString("ClockInfo","NumPath",(LPCTSTR)m_sFullNumPath,workpath);
itoa(m_12hour,tmpstr,10);
::WritePrivateProfileString("ClockInfo","24Hour",tmpstr,workpath);
itoa(m_touming,tmpstr,10);
::WritePrivateProfileString("ClockInfo","TouMingDu",tmpstr,workpath);
itoa(m_autorun,tmpstr,10);
::WritePrivateProfileString("ClockInfo","AutoRun",tmpstr,workpath);
if(m_autorun==TRUE)
{
char runpath[MAX_PATH];
GetModuleFileName(NULL,runpath,MAX_PATH);
CMyRegKey regKey;
regKey.RegOpen(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
regKey.RegWrite("12Clock",runpath);
regKey.RegClose();
}
else
{
CMyRegKey regKey;
regKey.RegOpen(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
regKey.RegDelValue("12Clock");
regKey.RegClose();
}
CDialog::OnOK();
}
void CSetupDlg::OnCustomdrawToumingslider(NMHDR* pNMHDR, LRESULT* pResult)
{
UpdateData();
m_slideredit=m_toumingslider.GetPos();
UpdateData(FALSE);
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -