Hi, I am starting a new project for PocketPC using MFC.
Does one need to use the DDX|\DDV functions. I usually use Win32
but this project i have been told to use MFC. I usually use the GetDlgitem
SetDlgItem etc to setup things in OnInitDialog so am a bit confused with
this
DDX stuff. Can some please clarify.

Many thanks

Re: DDX support by voidcoder

voidcoder
Tue Oct 02 03:17:22 PDT 2007


It is actually very simple to use. You are assigning
either the control itself or its value (eg. text for
edit control or selected item index for combobox etc)
with a variable. Next you can reference the control
(or its value) using that variable.

Here are some samples:

/////// Edit control DDX /////////////////

class CMyDialog : public CDialog
{
...
virtual void DoDataExchange(CDataExchange* pDX);
CEdit m_myEditControl1;
...
};

void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_EDIT1, m_myEditControl1);
}

Now you can easily access the control using
DDX var.

...
m_myEditControl1.SetWindowText(_T("My Text"));
m_myEditControl1.Cut();
m_myEditControl1.Paste();
...


/////// Edit control value DDX /////////////////

class CMyDialog : public CDialog
{
...
virtual void DoDataExchange(CDataExchange* pDX);
CString m_myEditText1;
...
};

void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_myEditText1);
}

Now you can set text by

myEditText1 = _T("My Text");
UpdateData(TRUE);

or get text by

UpdateData(FALSE);
CString currentEditText = myEditText1;


- Oleg


dev15 wrote:
> Hi, I am starting a new project for PocketPC using MFC.
> Does one need to use the DDX|\DDV functions. I usually use Win32
> but this project i have been told to use MFC. I usually use the GetDlgitem
> SetDlgItem etc to setup things in OnInitDialog so am a bit confused with
> this
> DDX stuff. Can some please clarify.
>
> Many thanks
>
>