Click to See Complete Forum and Search --> : MFC View


Claude Gagnon
April 26th, 1999, 07:03 AM
Hi,

In a MFC Doc/View application, when I want to access a member function of the Doc class from a view class, I write :

CMyProgramDoc* pDoc = GetDocument();

After that, I can pass pDoc to another class and I can access member functions of CMyProgramDoc class.

I want to do the same thing with CMyProgramView.
How can I do that ?

Thanks
Claude

Franky Braem
April 26th, 1999, 07:35 AM
I do this by creating a pointermember of the Viewclass in the documentclass :

CMyView *m_pView;



In the OnInitialUpdate of the viewclass I set this variable as follows :

CMyDoc *pDoc = (CMyDoc *) GetDocument();
pDoc->m_pView = this;




When you want to access multiple views you can use the GetNextView(), GetFirstViewPosition() methods of CDocument.