get a handler of Document in a user defined class

I have a SDI project, where I defined a class, say CMyClass,
within that class, I hope I can have a pointer to the
Document class, how can I do that ?

Your kind assistance will be highly appreciated.

Who is Participating?
jkrConnect With a Mentor Commented:
Well, there are several ways to achieve what you want - you could e.g. pass the pointer to the class' constructor and store it, use 'GetActiveDocument()' from the frame window, the 'GetDocument()' method in 'CView()' and lots of other ways...
wangzAuthor Commented:
I got the answer by searching the MFC FAQ:

((CFrameWnd*) (AfxGetApp()->m_pMainWnd))->GetActiveDocument()

Thanks anyway, jkr.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.