| 目標 | 代碼範例 | 說明 |
| 工具列 | CToolBar* pBar = (CToolBar*)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_TOOLBAR); | 預設 ID |
| 狀態列 | CStatusBar* pBar = (CStatusBar*)AfxGetMainWnd()->GetDescendantWindow(AFX_IDW_STATUS_BAR); | 預設 ID |
| 對話框控制項 | CButton* pBtn = (CButton*)GetDlgItem(IDC_MYBTN); | 視圖/對話框成員函數 |
| 控制項變數關聯 | ClassWizard → Member Variables → Add Variable (Ctrl+雙擊控制項) | 自動 DDX/DDV |
| 文檔 → 視圖 | POSITION pos = GetFirstViewPosition(); while(pos) { CView* p = GetNextView(pos); } | 遍歷所有視圖 |
| 視圖 → 文檔 | CDoc* pDoc = GetDocument(); // 內部 static_cast(m_pDocument) | 最常用 |
| 框架 → 文檔/視圖 | CDoc* pDoc = (CDoc*)GetActiveDocument(); CView* pView = (CView*)GetActiveView(); | MDI/SDI 通用 |
| 應用程式 | CMyApp* pApp = (CMyApp*)AfxGetApp(); | 全域唯一 |
| 主框架 | CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); | SDI/MDI 主框架 |
| 滑鼠點擊子視窗 | CWnd* pChild = ChildWindowFromPoint(pt, CWP_SKIPINVISIBLE); | 回傳偽指標,勿長期持有 |