MFC (Access to CView from Anywhere).
This is the cheats way of getting access to
CView from anywhere in your application.
- In you
CWinApp, create two functions: a
StoreMyView (CView* pView) and a
- Declare a pointer of type
CView in the
CView constructor, get the application using the following lines:
CWinApp* pApp = (CWinApp*) AfxGetApp ();
CWinApp GetMyView (), return your declared pointer.
CWinApp StoreMyView, point your data member to the parameter value, i.e. say, data member is
m_pView and parameter is
- Now you can access your view using the application object, i.e.,
CWinApp * pApp = (CWinApp*) AfxGetApp ();
CView * pView = pApp. GetMyView ();
- Don't forget to include View.h and Doc.h in CWinApp.h and the view.h is included in .cpp files automatically when you create your data member in VC++.
That's all folks.
Any comments, mail to: firstname.lastname@example.org.
2001-01-15 - First release