[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2004-10-29
4
Medium Priority
?
375 Views
Last Modified: 2013-11-20
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
Comment
Question by:urivera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Assisted Solution

by:Amritpal Singh
Amritpal Singh earned 60 total points
ID: 12450691
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
 
LVL 6

Expert Comment

by:Amritpal Singh
ID: 12450695
0
 
LVL 48

Accepted Solution

by:
AlexFM earned 90 total points
ID: 12450720
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
 

Author Comment

by:urivera
ID: 12490852
Thanks for your replies
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question