customdd.cpp
来自「讲mfc的书」· C++ 代码 · 共 35 行
CPP
35 行
#include <stdafx.h>
#include "customdd.h"
// Custom Exchange
void DDX_EnableWindow(CDataExchange *pDX, int id, BOOL &flag)
{
CWnd *ctl=pDX->m_pDlgWnd->GetDlgItem(id);
if (pDX->m_bSaveAndValidate)
flag=ctl->IsWindowEnabled();
else
ctl->EnableWindow(flag);
}
// Custom validator
void DDV_MinMaxCurrency(CDataExchange *pDX, float val, float min, float max)
{
CWnd *editctl=CWnd::FromHandle(pDX->m_hWndLastControl);
CString s;
int n;
if (pDX->m_bSaveAndValidate)
{
// Using math to decide if anything is left over is bad because of rounding
// errors, so use a string method instead
editctl->GetWindowText(s);
n=s.Find('.');
if (n!=-1 && n+3<s.GetLength())
{
AfxMessageBox("Please enter the data to the nearest penny!");
pDX->Fail();
}
DDV_MinMaxFloat(pDX,val,min,max); // let the existing one do the job
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?