📄 timedlg.cpp
字号:
// TimeDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TimeTest.h"
#include "TimeDlg.h"
#include "GoodTime.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTimeDlg dialog
CTimeDlg::CTimeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTimeDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTimeDlg)
m_nDay = 0;
m_nHour = 0;
m_nMinute = 0;
m_nSecond = 0;
m_nYear = 0;
//}}AFX_DATA_INIT
}
void CTimeDlg::DoDataExchange(CDataExchange* pDX)
{
int nMaxDays;
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTimeDlg)
DDX_Control(pDX, IDC_MONTH, m_cbMonth);
DDX_Text(pDX, IDC_DAY, m_nDay);
DDX_Text(pDX, IDC_HOUR, m_nHour);
DDV_MinMaxInt(pDX, m_nHour, 0, 23);
DDX_Text(pDX, IDC_MIN, m_nMinute);
DDV_MinMaxInt(pDX, m_nMinute, 0, 59);
DDX_Text(pDX, IDC_SEC, m_nSecond);
DDV_MinMaxInt(pDX, m_nSecond, 0, 59);
DDX_Text(pDX, IDC_YEAR, m_nYear);
DDV_MinMaxInt(pDX, m_nYear, 1900, 9999);
//}}AFX_DATA_MAP
// Set the selection according to a numeric month
if ( pDX->m_bSaveAndValidate )
{
m_nMonth = m_cbMonth.GetCurSel() + 1;
}
else
{
if ( IsWindow(m_cbMonth.m_hWnd) )
{
m_cbMonth.SetCurSel( m_nMonth - 1 );
}
}
switch ( m_nMonth )
{
case 1: // January
case 3: // March
case 5: // May
case 7: // July
case 8: // August
case 10: // October
case 12: // December
nMaxDays = 31;
break;
case 4: // April
case 6: // June
case 9: // September
case 11: // November
nMaxDays = 30;
break;
case 2:
nMaxDays = (CGoodTime::IsLeapYear(m_nYear) ? 29 : 28);
break;
default: // Bad month
nMaxDays = 0;
ASSERT(FALSE);
}
// Validate this late to check for variable days in a month
pDX->PrepareEditCtrl(IDC_DAY);
DDV_MinMaxInt(pDX, m_nDay, 1, nMaxDays);
}
BEGIN_MESSAGE_MAP(CTimeDlg, CDialog)
//{{AFX_MSG_MAP(CTimeDlg)
ON_BN_CLICKED(IDC_USE_CURRENT, OnUseCurrentTime)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTimeDlg message handlers
void CTimeDlg::OnUseCurrentTime()
{
// Get the current time
CGoodTime t = CGoodTime::GetCurrentTime();
// Set the default time
m_nDay = t.GetDay();
m_nHour = t.GetHour();
m_nMinute = t.GetMinute();
m_nSecond = t.GetSecond();
m_nYear = t.GetYear();
m_nMonth = t.GetMonth();
UpdateData( FALSE );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -