Click to See Complete Forum and Search --> : MFC pointers
Andre Schuetz
June 5th, 1999, 01:20 PM
Hello
I need to get a pointer to the View Class of an SDI app. for use within a global function written in the App class.
Thanks very much in advance.
Masaaki
June 5th, 1999, 04:43 PM
Hi.
I often use this syntax.
((CView*)(AfxGetMainWnd()))->public member funciton or variable of CView.
Also, you can change the cast like CMainWin(from CFrameWnd) or CWinApp.
There may be a mistake of brace.
HTH.
-Masaaki Onishi-
balak yap
June 6th, 1999, 08:55 PM
Masaaki is right, but you have to take care the view class name,
for example
#include "CYourView.h"
.....
....
//View class pointer and variable
CFrameWnd* pFrame=(CFrameWnd*)AfxGetMainWnd();
CYourView* pView=(CYourView*)pFrame->GetActiveView();
...
...
then you get the pointer of your view class..
just point to any member variable of member function you want..
...
pView->m_variable = 123;
..
..
HTH
Hello World!!!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.