[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 389
  • Last Modified:

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?

Thanks.
0
urivera
Asked:
urivera
  • 2
2 Solutions
 
Amritpal SinghCommented:
hi
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

https://www.aut.utt.ro/e-books/books5/1556225121/ch07/264-267.html#Heading13
0
 
Amritpal SinghCommented:
0
 
AlexFMCommented:
Add public class members to the child class dialog:

class CChildDialog
{
public:
   
    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.
0
 
uriveraAuthor Commented:
Thanks for your replies
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now