dateutil.cpp

来自「API经典入门」· C++ 代码 · 共 35 行

CPP
35
字号
// This file contains the implementations for utilities 
// relating to CDate.
// Filename : DateUtil.cpp

#include "stdafx.h"
#include "DateUtil.h"

void AFXAPI DDX_Text(CDataExchange* pDX, int nIDC, CDate& value)
{
	HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);
	CString tempS;
	
	if (pDX->m_bSaveAndValidate)
	{
		int nLen = ::GetWindowTextLength(hWndCtrl);
		::GetWindowText(hWndCtrl, tempS.GetBufferSetLength(nLen), nLen+1);
		if (tempS.IsEmpty())
			value = CDate(); // Null date
		else if (!value.StringToDate(tempS))
		{
			AfxMessageBox("Invalid Date!");
			tempS.Empty();
			// Fail will throw an exception whose alternate
			// flow of control will bypass the normal end-scope
			// clean-up.  Therefore we must manually destroy
			// dynamic objects like CString.
			pDX->Fail();
		}
	}
	else
	{
		::SetWindowText(hWndCtrl, value.DateString());
	}
}

⌨️ 快捷键说明

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