TA的每日心情 | 开心 2024-02-17 18:16 |
---|
签到天数: 14 天 [LV.3]偶尔看看II
管理员
这里没有广告...
- 积分
- 10709
|
最简单直观的:
CString str;
GetDlgItemText(IDC_EDIT_TEST, str);
int d=atoi(str.GetBuffer(0));
更优雅的:
.h:int m_editTest;
.cpp:
void CxxDlg::DoDataExchange(CDataExchange* pDX)
{
DDX_Text(pDX, IDC_EDIT_TEST, m_editTest);
}
这样就绑定了控件和一个数据变量,当控件数据发生变化Updatedata(TRUE)后就会反映到变量上。其他类型变量也一样。
Updatedata(TRUE) :将控件的值赋值给成员变量;
Updatedata(FALSE) : 将成员变量的值赋值给控件。
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, BYTE& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, short& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, int& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, UINT& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, long& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, DWORD& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, CString& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, float& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, double& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, COleCurrency& value );
void AFXAPI DDX_Text( CDataExchange* pDX, int nIDC, COleDateTime& value );
|
|