Passing values between dialogs.

I have an SDI application with a formview.  I have popup modeless and modal dialogs. I would like to share variables between these dialogs.

Would you please give me an example of how I can pass variables.

Thank you

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can either create a global variable, or declare the variable in one class, and pass a pointer to the other class.
You can use the view's document for this purpose. For eg. you may want to have a status variable or flag -

1. Declare the variable in the CDocument derived class

class CMyDoc:public CDocument {
public :
int flag;

2. Include the header file in your popup modeless dialog class CPP files

3. Use the GetDocument method to get a pointer to the document and access the variable flag in the following manner :

CMyView *pView = (CMyView *) GetActiveView();
CMyDoc *pDoc = (CMyDoc *) pView->GetDocument();

int flag = pDoc->flag;

Hope this helps.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fstab: Please post as comment, until an answer is accepted. Otherwise, the question is locked, keeping other experts from viewing it.
That's the basic idea - if I think I have the answer I should post it as an answer - other experts can still view it and post a comment .. in case my answer is rejected the person who posted the correct answer as a comment can still get points .. its all in the hands of (in this case) ducksoup ..
Vinayak KumbarSr Program ManagerCommented:

The best way(and the commonly used method) is to declare those variables in App class and access them anywhere in the application.

If Ur application is Test

then declare the flag(for ex) m_bFlag in CTestApp.h

Then U can access it as

((CTestApp *)AfxGetApp())->m_bFlag

Try it out.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.