CMainframe类和Cview类怎么进行数据交互

zhqi1234 2011-03-26 03:23:41
小弟最近初学MFC,在Cmainframe类中添加了一个Cdlgbar,然后在Cdlgbar对应的对话框资源上设置了几个radio button,button等等,我现在想在view类中知道我这几个radio button到底哪个被选中,应该怎么实现?
...全文
139 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
lazio88 2011-03-26
  • 打赏
  • 举报
回复
在你的view中
#include "mainframe.h"
调用
CMainFrame* pMainFrame = (CMainFrame* )AfxGetMainWnd();
pMainFrame ->dlgbar.
King_hhuang 2011-03-26
  • 打赏
  • 举报
回复
AfxGetMainWnd
AfxGetApp()->m_pMainWnd
Eleven 2011-03-26
  • 打赏
  • 举报
回复
AfxGetMainWnd()得到主框架窗口的指针
VC天下 2011-03-26
  • 打赏
  • 举报
回复
获取MainFrame指针,实现交互
CMainFrame *pMain = (CMainFrame *) AfxGetApp()->m_pMainWnd;//获取MainFrame指针
zhuhuigong 2011-03-26
  • 打赏
  • 举报
回复
GetParentFrame()
GetActiveView()
向立天 2011-03-26
  • 打赏
  • 举报
回复
也可以在radio button切换时产生消息的时候发个自定义消息到view里更新相应变量
CppCoder 2011-03-26
  • 打赏
  • 举报
回复
用一个全局变量保存选中的radio,在cview中访问这个全局变量
Dreadnought 2011-03-26
  • 打赏
  • 举报
回复
在View中包含MainFrame的头文件然后添加如下代码

CMainFrame *pMain = (CMainFrame *) AfxGetApp()->m_pMainWnd;//获取MainFrame指针

m_pMainWnd->m_RadioBtn.GetCheck( );
fishion 2011-03-26
  • 打赏
  • 举报
回复
在view中调用
CMainFrame* pMainFrame = (CMainFrame* )AfxGetMainWnd();
pMainFrame ->dlgbar...类似这样

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧