现在的位置: 首页 > 综合 > 正文

获取CMainFrame类指针

2013年02月20日 ⁄ 综合 ⁄ 共 845字 ⁄ 字号 评论关闭

1)CMainFrame: 
     GetActiveView()可得到View指针。
     GetActiveDocument()可得到Document指针。
2)CDoc:
     POSITION pos = GetFirstViewPosition();
     CView* pView = GetNextView(pos); //得到View指针
     AfxGetMainWnd()可得到MainFrame指针
3) CView:
     GetDocument()可得到CDoc指针。
     AfxGetMainWnd()可得到MainFrame指针
-------------------------------------------------------
CMainFrame*  pMain=(CMainFrame*)AfxGetMainWnd();
-------------------------------------------------------
用向导建立一个单文档/多文档程序,其中最外面的框架叫做   frame   ,包括标题、最大最小化按钮、菜单、工具条、以及   view   等都在   frame   中。frame   中,中间那块白色的部分被   view   占据。 

AfxGetMainWnd()   就是取得此   frame   的指针,m_hWnd   是此   frame   的窗口句柄
----------------------------------------------------------
AfxGetMainWnd()   就是获得应用程序主窗口的指针,AfxGetMainWnd()-> m_hWnd是主窗口的句柄。
-----------------------------------------------------------
在App中获得MainFrame指针 
CWinApp   中的   m_pMainWnd变量就是MainFrame的指针 
也可以:   CMainFrame   *pMain   =(CMainFrame   *)AfxGetMainWnd(); 

抱歉!评论已关闭.