How can I access member variables in CMyView from popup dialogs?

I have an SDI FormView application with popup dialogs.  I would like to have access to the member variables on the main dialog from the popup dialogs.

How can I reference the CMyView (FormView) in my popup dialogs?

Could you please give me an example of how I could do this.

Thank you.
drodgersAsked:
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.

Vinayak KumbarSr Program ManagerCommented:
Hi,

U can do it in two ways.
1. maitain the variables in the app class and acces it using AfxGetApp()...
2. If pop up dialogs are childs of Ur main window, then in the child dialog use
GetParent()->m_ParentVar;
where m_ParentVar i sthe variable in the parent class.

Hope it helps.
VinExpert
0

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
Vinayak KumbarSr Program ManagerCommented:
Hi,

U can maintain those variables in the mainframe also.
say a variable m_ParentVar.
If it is declared in mainframe.h, then to access it
CMainFrame* l_pMain = (CMainFrame*)AfxGetMainWnd();
l_pMain->m_ParentVar will give u that variable.

If it is declared in app.h and Ur App class is CMyApp, then to access it
CMyApp *pApp = (CMyApp *)AfxGetApp();
pApp->m_ParentVar will give u that variable.

If the variable is one dialog and it pops up another dialog, and u want to access that variable from the poped up dialog, then
in the poped up dialog
GetParent()->m_ParentVar will give u that variable. or u can also use this->GetParent()->m_ParentVar to access it.

Try it out.
VinExpert
0
drodgersAuthor Commented:
Thank you for your help VinExpert.  I am still having a hard time with the member variables in my CView class.  I think it's because my CFormView is protected and I don't know how to get around that.  Thanks again.
0
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.