如何获取视图的指针 在文档视图结构中,想要在文档打开/创建(OpenDocumentFile)的时候获取该文档的视图指针,应该怎样做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CView* pView = AfxGetMainWnd()->GetActiveView(); orCView* pView = AfxGetMainWnd()->GetActiveFrame()->GetActiveView(); 1) 在View中获得Doc指针 CYouSDIDoc *pDoc=GetDocument();一个视只能有一个文档。2) 在App中获得MainFrame指针CWinApp 中的 m_pMainWnd变量就是MainFrame的指针也可以: CMainFrame *pMain =(CMainFrame *)AfxGetMainWnd();3) 在View中获得MainFrame指针 CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;4) 获得View(已建立)指针 CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;CyouView *pView=(CyouView *)pMain->GetActiveView();5) 获得当前文档指针 CDocument * pCurrentDoc =(CFrameWnd *)m_pMainWnd->GetActiveDocument();6) 获得状态栏与工具栏指针 CStatusBar * pStatusBar=(CStatusBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR);CToolBar * pToolBar=(CtoolBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR);7) 如果框架中加入工具栏和状态栏变量还可以这样 (CMainFrame *)GetParent()->m_wndToolBar;(CMainFrame *)GetParent()->m_wndStatusBar;8) 在Mainframe获得菜单指针 CMenu *pMenu=m_pMainWnd->GetMenu();9) 在任何类中获得应用程序类用MFC全局函数AfxGetApp()获得。 编辑框 LineScroll 移动文字如何解决重叠问题? 网页为何不能响应ActiveX事件 CString问题 请问如何用wininet通过有认证的代理服务器访问http? 请问怎么用树控件读ACCESS数据库里的数据显示在树~并且选中树后可以在一个编辑框里显示出来 为何必示我的EditBox???? UDP服务端怎么判断有数据到达? codewarrior进来 初学者的问题 怎么设置一个目录的属性? 求高手指点dll安装遇到的怪问题 如下代码,我想让m_edit显示m_mc个字符,总不正常!望指教,有没有更好的办法?谢谢!
CWinApp 中的 m_pMainWnd变量就是MainFrame的指针
也可以: CMainFrame *pMain =(CMainFrame *)AfxGetMainWnd();3) 在View中获得MainFrame指针 CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;4) 获得View(已建立)指针 CMainFrame *pMain=(CmaimFrame *)AfxGetApp()->m_pMainWnd;CyouView *pView=(CyouView *)pMain->GetActiveView();5) 获得当前文档指针 CDocument * pCurrentDoc =(CFrameWnd *)m_pMainWnd->GetActiveDocument();6) 获得状态栏与工具栏指针 CStatusBar * pStatusBar=(CStatusBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR);CToolBar * pToolBar=(CtoolBar *)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR);7) 如果框架中加入工具栏和状态栏变量还可以这样 (CMainFrame *)GetParent()->m_wndToolBar;(CMainFrame *)GetParent()->m_wndStatusBar;8) 在Mainframe获得菜单指针 CMenu *pMenu=m_pMainWnd->GetMenu();9) 在任何类中获得应用程序类
用MFC全局函数AfxGetApp()获得。