0
我想從我的主機訪問分離器內的視圖。目前我有這個:MFC:從主機訪問視圖
CWnd * pView = m_wndSplitter.GetPane(0,0);
但是,這讓我一個指向CWnd而不是CMyViewClass對象的指針。
任何人都可以向我解釋我需要做什麼才能訪問視圖對象本身,因此我可以以pView-> ViewFunction(...)的形式訪問成員函數;
我想從我的主機訪問分離器內的視圖。目前我有這個:MFC:從主機訪問視圖
CWnd * pView = m_wndSplitter.GetPane(0,0);
但是,這讓我一個指向CWnd而不是CMyViewClass對象的指針。
任何人都可以向我解釋我需要做什麼才能訪問視圖對象本身,因此我可以以pView-> ViewFunction(...)的形式訪問成員函數;
只投它:
// using MFC's dynamic cast macro
CMyViewClass* pMyView =
DYNAMIC_DOWNCAST(CMyViewClass, m_wndSplitter.GetPane(0,0));
if (NULL != pMyView)
// whatever you want to do with it...
或:
// standard C++
CMyViewClass* pMyView =
dynamic_cast<CMyViewClass*>(m_wndSplitter.GetPane(0,0));
if (NULL != pMyView)
// whatever you want to do with it...
如果您知道,在窗格0,0
的觀點永遠是CMyViewClass
類型,那麼你可以只使用static_cast
..但是我建議你不要 - 如果你改變佈局,沒有任何意義上的風險。