datetimesheet.cpp

来自「深入浅出Visual C++入门进阶与应用实例 随书光盘 作者 何志丹」· C++ 代码 · 共 77 行

CPP
77
字号
// DataTimeSheet.cpp : implementation file
//

#include "stdafx.h"
#include "Ex050105.h"
#include "DateTimeSheet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDataTimeSheet

IMPLEMENT_DYNAMIC(CDateTimeSheet, CPropertySheet)

CDateTimeSheet::CDateTimeSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
{
	AddPage(&m_datePage);
	AddPage(&m_timePage);
}

CDateTimeSheet::CDateTimeSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
:CPropertySheet(pszCaption, pParentWnd, iSelectPage)
{
	AddPage(&m_datePage);
	AddPage(&m_timePage);
}

CDateTimeSheet::~CDateTimeSheet()
{
}

BEGIN_MESSAGE_MAP(CDateTimeSheet, CPropertySheet)
//{{AFX_MSG_MAP(CDateTimeSheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL CDateTimeSheet::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	if(IDOK == wParam)
	{
		CString strDateTime ;
		CTime t ;
		
		CString strDate ;
		m_datePage.m_dateCtrl.GetTime(t);
		strDate = t.Format("%Y-%m-%d");
		strDateTime += ( "\n" + strDate ) ;
		
		CString strTime ;
		m_timePage.m_timeCtrl.GetTime(t);
		strTime = t.Format("%H-%M-%S");
		strDateTime += ( "\n" + strTime ) ;
		
		AfxMessageBox(strDateTime);
		
	}
	
	return CPropertySheet::OnCommand(wParam, lParam);
}

BOOL CDateTimeSheet::OnInitDialog() 
{
	BOOL bResult = CPropertySheet::OnInitDialog();
	
	SetActivePage(1);//生成此page
	SetActivePage(0);
	
	return bResult;
}

⌨️ 快捷键说明

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