markgooding
asked on
How to get the runtime class?
I've created a Doc/View architecture application using MFC. I have a number of view class types derived from a parent view class, which itself is derived from CView. During the program execution I get the currently active view using line 1 below. I want to then call a function on that view, but at the child class level not the parent, or CView, level. Is there a way to do that without repeating lines 3-5 below for each class?
CView* testview = ((CFrameWnd*) AfxGetApp()->m_pMainWnd))->GetActiveView();
if(testview->IsKindOf(RUNTIME_CLASS(CMyChildView))){
((CMyChildView*)testview)->DoSomething();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER