What is the Equivalent of AfxGetApp to the Application Document?
I have an SDI document that has several dialogs. I declare a member variable from my app.h. I access this member from any dialog of the application using AfxGetApp.
What I want to do, I want to declare a member variable on my doc.h where I want to access that member from other dialog. Since AfxGetApp return a pointer to the application class and I am working in the document class, I wonder if I can use GetDocTemplate to access the member of the document class from any other dialog as I did from the application class.
3. I access member variable from doc.h on the form of. I also added doc.h to where I call the function below.
Code:
CMyDocumentClass::GetDoc()->m_MemberVariable;
Question:
Was it necessary to do all this coding? Was there another way to access member variable from the doc.h anywhere from my program?
The problem was, I wanted to access member variable from my doc.h anywhere from my program.
To answer the question somewhat depends on where you create the dialog from.
In many cases, the handler that creates the dialog will be in your view class (or perhaps the MainFrame). When I create the dialog, I generally add a member variable to the dialog header as:
Code:
CMyDocumentClass* m_pDoc;
If the handler that creates the dialog is in MainFrame (perhaps a menu item that shows the dialog) then I would do this:
Bookmarks