Let's take ListBox and Edit as examples.
2025-11-10
Written by: xiaobin
Add Variable:

| Name | Description |
|---|---|
| DDX_CBIndex | Initializes or retrieves the index of the current selection of a combo box control. |
| DDX_CBString | Initializes or retrieves the current contents of the edit field of a combo box control. |
| DDX_CBStringExact | Initializes or retrieves the current contents of the edit field of a combo box control. |
| DDX_Check | Initializes or retrieves the current state of a check box control. |
| DDX_Control | Subclasses a given control within a dialog box. |
| DDX_DateTimeCtrl | Initializes or retrieves date and/or time data of a date and time picker control. |
| DDX_IPAddress | Initializes or retrieves the current value of an IP address control. |
| DDX_LBIndex | Initializes or retrieves the index of the current selection of a list box control. |
| DDX_LBString | Initializes or retrieves the current selection within a list box control. |
| DDX_LBStringExact | Initializes or retrieves the current selection within a list box control. |
| DDX_ManagedControl | Creates a .NET control matching the control’s resource ID. |
| DDX_MonthCalCtrl | Initializes or retrieves the current value of a month calendar control. |
| DDX_Radio | Initializes or retrieves the 0-based index of the radio control that is currently checked within a radio control group. |
| DDX_Scroll | Initializes or retrieves the current position of a scroll control’s thumb. |
| DDX_Slider | Initializes or retrieves the current position of a slider control’s thumb. |
| DDX_Text | Initializes or retrieves the current value of an edit control. |
m_Types.AddString(_T("MS-Access"));
m_Types.AddString(_T("MSSQL"));
m_Types.AddString(_T("MySQL"));
for example:
int iCurSel = 0;
iCurSel = m_Types.GetCurSel();
CString tmp;
tmp.Format(_T("%d"), iCurSel);
AfxMessageBox(tmp);
void CMFCApplication1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, m_Server);
}
change:
void CMFCApplication1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_Server);
}
Otherwise, the following will occur:
error C2664: 'void DDX_Control(CDataExchange *,int,CWnd &)' : cannot convert argument 3 from 'CString' to 'CWnd &'
m_Types.GetText(iCurSel, tmp);
m_Server = tmp;
// Update the display
UpdateData(FALSE);