MFC:从大型机访问视图
MFC: Accessing Views from Mainframe
我正试图从大型机访问拆分器内部的视图。目前我有这个:
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
。。。但我建议你不要——如果你改变布局,冒着问题的风险毫无意义。
相关文章:
- 通过方法访问结构
- 使用不带参数的函数访问结构元素
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如果我只是不访问queue_front节点的子节点,而是将它们推到队列中呢?还是BFS吗
- 用于访问容器<T>数据成员的正确 API
- 访问者访问变体并返回不同类型时出错
- 从资源视图访问对话框时出现问题
- 在计算着色器中的无序访问视图中写入纹理记录
- 从C++访问列表视图委托的文本
- 循环访问列表视图项 win32 api
- 从对话框中对窗体视图项进行mfc访问
- boost::融合访问联合视图的键类型作为地图
- 循环访问提升::multi_array视图
- RootViewController 在其委托外部访问时不会添加子视图
- Qt:如何同步访问数据从多个线程在模型/视图设置
- 如何访问Qtitan视图的滚动条?
- 当单击视图中的项时,从另一个小部件访问自定义模型数据
- 共享文件视图-访问控制
- Qml访问列表视图项
- MFC:从大型机访问视图