Click to See Complete Forum and Search --> : Data communication between two dialogs


Shahzad
April 8th, 1999, 09:07 AM
CListCtrl m_ListCtrl; // a member variale in dialog1

I am currently in dialog2, and I want to call dialog1, and to fill it with the data in the parent dialog.

CDialog1 dlg;
dlg.DoModal();

How shall I fill m_ListCtrl with data from dialog2?

Please tell me how to pass pointers. A piece of code will be highly appreciated.
thankyou in advance.

Vladimir Milyaev
April 8th, 1999, 09:25 AM
Hi!
I think you should share data at the layer of parent window. Or share method...

Best regards, Bob.

Shahzad
April 8th, 1999, 09:43 AM
I am afriad I didn't get your point enough to be able to implement it. Can you elaborate this a little more.
I appreciate your help.

yash
April 8th, 1999, 09:50 AM
Hi,
In Dialog1 Class provide public member function to set the values of the variables that U think need to be done from the Dilaog2 class. Then in Dilaog2, just b4 U call Dlg1.DoModal() set those values .

ex:

class Dialog1
{
private
int ValuefromDilaog2 ;

public:

void SetvaluefromDilaof2( int val )
..
..
} ;

class Dialog1::SetvaluefromDilaof2( int val )
{
ValuefromDilaog2 = val ;
}



now in Dialog 2 one function

void Dialog2::MyFunction()
{
Dilaog1 dlg1 ;

dlg1.SetvaluefromDilaof2( 123 );
dlg1.DoModal() ;
}

Hope this helps You.
Good Luck.
Yash.

Shahzad
April 8th, 1999, 10:32 AM
thankx for the help. I will try to implent it.

Vladimir Milyaev
April 9th, 1999, 02:00 AM
And if you called Dialog2 within Dialog1 then

void Dialog2::MyFunction()
{
((Dialog1*)GetParent())->SetvaluefromDilaof2( 123 );
}

But in this case both classes must know about each other.

Best regards, Bob.