在新建类中获取其他的类

GET App
       、、、、、AfxGetInstanceHandle()
       、、、、、AfxGetApp()
      GET Frame->View->Document 获取视图
       、、、、、SDI AfxGetMainWnd() -> GetActiveView() ->  GetDocument()
       、、、、、MDI AfxGetMainWnd() -> MDIGetActive() -> GetActiveView() ->
                                                                GetDocument()
       GET Menu 获取菜单
      、、、、、CMenu *pMenu=AfxGetApp()->m_pMainWnd->GetMenu();
       GET ToolBar,StatusBar 获取工具栏 状态栏
       、、、、、(CMainFrame *)GetParent()->m_wndToolBar;
       、、、、、(CMainFrame *)GetParent()->m_wndStatusBar;
       、、、、、CStatusBar * pStatusBa=(CStatusBar *)AfxGetMainWnd()->
                                         GetDescendantWindow(AFX_IDW_STATUS_BAR);
       、、、、、CToolBar * pToolBar=(CtoolBar *)AfxGetMainWnd()->
                                          GetDescendantWindow(AFX_IDW_TOOLBAR);
       Get View from Document
       、、、、、GetFirstViewPosition 和 GetNextView 函数得到指针。  
最后提醒:
       、、、、、在提取到各个句柄之后,因为初次提取的都是标准类句柄,所以,在使用时要注意将标准句柄转换成自己的类的句柄。
       、、、、、((CMyApp*)AfxGetApp())->XXXX();//这的xxxx()就是你定义的类中间的成员

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章