我用MFC写的控件是可以用多种数据类型的
class CInputDlg : public CDialog
{
DECLARE_DYNAMIC(CInputDlg)
public:
CInputDlg(CWnd* pParent = NULL);
// 标准构造函数
virtual ~CInputDlg();
// 对话框数据
enum { IDD = IDD_INPUTDLG };
protected:
virtual void DoDataExchange(CDataExchange* pDX);
// DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
CString m_sName;
CString m_sMnem;
int m_iMath;
int m_iEng;
int m_iComp;
};
===============================
void CInputDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_NAME, m_sName);
DDV_MaxChars(pDX, m_sName, 100);
DDX_Text(pDX, IDC_MNEM, m_sMnem);
DDV_MaxChars(pDX, m_sMnem, 1);
DDX_Text(pDX, IDC_MATH, m_iMath);
DDV_MinMaxInt(pDX, m_iMath, 0, 100);
DDX_Text(pDX, IDC_ENG, m_iEng);
DDV_MinMaxInt(pDX, m_iEng, 0, 100);
DDX_Text(pDX, IDC_COMP, m_iComp);
DDV_MinMaxInt(pDX, m_iComp, 0, 100);
}
用DDX影射就可以取到相关的值了。