How do I transfer data from child dialog to the parent Cformview?

I am new to MFC programming and I'm trying to transfer data (for example, which check boxes were checked or which radio button was selected) from a child dialog to the parent formview.  The formview needs to know what was selected in the child dialgo box.  I want to update a static text control or a editable text control in the formview, once the user has clicked on the "OK" button on the child dialog box.  I am using MFC document/view architecture and my application is a SDI.  Can someone provide me with some ideas on which is the best way for the parent formview be aware on what was selected in the child dialog?

Who is Participating?
Add public class members to the child class dialog:

class CChildDialog
    int m_nRadioSelection;
    CString m_sText;

Fill these members in OnOK:

void CChildDialog::OnOK()
    m_nRadioSelection = ...;
    m_sText = ...;

Get their values from the parent class:

void CParent::OnShowChild()
    CChildDialog dlg(this);
    if ( dlg.DoModal == IDOK )
        // ise dlg.m_nRadioSelection and dlg.m_sText here

Notice that m_nRadioSelection and m_sText should not be members linked to dialog controld using DDX. You may keep another class members for this, and use their values to set output data in OnOK.
Amritpal SinghCommented:
for transferring information in case of dialogs u use the technique known as Dialog Data Exchange (or DDX).
u have to declare member function in ur data class ,that will correspond to each control .
then u'll use DoDataExchange for actual transfer

for an example have a look at the following link
Amritpal SinghCommented:
uriveraAuthor Commented:
Thanks for your replies
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.