在新建類中獲取其他的類

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()就是你定義的類中間的成員

 

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