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.
Still doesn't work, but is seems like I am on the right track
what you suggested to me doesn't work. I order to make it work, I have to do more coding. What I did, I
1. I added up a static member function to my document header file on the form of
2. I implemented the following function in my doc.cpp
class CMyDocumentClass: public CDocument
static CMyDocumentClass *GetDoc();
3. I access member variable from doc.h on the form of. I also added doc.h to where I call the function below.
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
return (CMyDocumentClass *) pFrame->GetActiveDocument();
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.