Pass info class to class
-
Class CSDITest1Doc creates a new instance of a dialog class. Works OK. Example below:
CTestDlg* aDlg = new CTestDlg();
//code is in CSDITest1Doc From class CSDITest1Doc I can execute functions of the new CTestDlg. For example, LoadMessage() is a function of CTestDlg. Works OK. Example below:aDlg->LoadMessage();
//this code is in CSDITest1Doc Sometimes I want to alert CSDITest1Doc of something that happens in CTestDlg. Sometimes I want CTestDlg to ask for data from CSDITest1Doc. Suppose XYZ() is a function of CSDITest1Doc. How do I execute a XYZ()of CSDITest1Doc from CTestDlg? -
Class CSDITest1Doc creates a new instance of a dialog class. Works OK. Example below:
CTestDlg* aDlg = new CTestDlg();
//code is in CSDITest1Doc From class CSDITest1Doc I can execute functions of the new CTestDlg. For example, LoadMessage() is a function of CTestDlg. Works OK. Example below:aDlg->LoadMessage();
//this code is in CSDITest1Doc Sometimes I want to alert CSDITest1Doc of something that happens in CTestDlg. Sometimes I want CTestDlg to ask for data from CSDITest1Doc. Suppose XYZ() is a function of CSDITest1Doc. How do I execute a XYZ()of CSDITest1Doc from CTestDlg?Oliver123 wrote:
How do I execute a XYZ()of CSDITest1Doc from CTestDlg?
One way is to pass a
CSDITest1Doc
pointer to theCTestDlg
instance.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Oliver123 wrote:
How do I execute a XYZ()of CSDITest1Doc from CTestDlg?
One way is to pass a
CSDITest1Doc
pointer to theCTestDlg
instance.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
I tried this, but found I didn't really know what to load into the pointer. In
CSDITest1Doc
I entered the following code. I figured if I could get the pointeraDoc
loaded with the address of the instance ofCSDITest1Doc
, I could call a function fromCTestDlg
, and use that to pass the pointer to CTestDlg.CSDITest1Doc* aDoc; aDoc = ???????
Is this a correct approach? Thanks -
I tried this, but found I didn't really know what to load into the pointer. In
CSDITest1Doc
I entered the following code. I figured if I could get the pointeraDoc
loaded with the address of the instance ofCSDITest1Doc
, I could call a function fromCTestDlg
, and use that to pass the pointer to CTestDlg.CSDITest1Doc* aDoc; aDoc = ???????
Is this a correct approach? ThanksOliver123 wrote:
Is this a correct approach?
No. Try:
CTestDlg* aDlg = new CTestDlg(this); //code is in CSDITest1Doc
Remember to create an appropriate
CTestDlg
constructor.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne