MFC: mainframe access
I am trying to access a view inside a splitter from my mainframe. At the moment I have this:
CWnd * pView = m_wndSplitter.GetPane (0, 0);
However, this gives me a pointer to a CWnd object, not a CMyViewClass object.
Can someone explain to me what I need to do to access the view object itself so that I can access the member functions in the form pView-> ViewFunction (...);
0
source to share
1 answer
Just throw it:
// using MFC dynamic cast macro
CMyViewClass* pMyView =
DYNAMIC_DOWNCAST(CMyViewClass, m_wndSplitter.GetPane(0,0));
if ( NULL != pMyView )
// whatever you want to do with it...
or
// standard C++
CMyViewClass* pMyView =
dynamic_cast<CMyViewClass*>(m_wndSplitter.GetPane(0,0));
if ( NULL != pMyView )
// whatever you want to do with it...
If you know that the view in the panel 0,0
will always be of type CMyViewClass
, then you can just use static_cast
... but I recommend that you don't - there is no point in risking problems if you ever change your layout.
+3
source to share