DYNAMIC_DOWNCAST(class, pointer) 参数class 类的名称。pointer 一个指针,它要强制转换为指向 class 类型对象的指针。备注该宏会将 pointer 参数强制转换为指向 class 参数类型的对象的指针。如果指针引用的对象是某种已标识的类,则宏将返回相应的指针。 如果强制转换不合法,则宏返回 NULL。STATIC...
STATIC_DOWNCAST 將物件指標從一個類別轉換成相關類型的指標。 在偵錯組建中,如果物件不是目標型別的「種類」,則會導致 ASSERT。 DYNAMIC_DOWNCAST 提供一個方便的方式,在檢查轉換是否合法時,將指標轉換成類別物件的指標。 複製 DYNAMIC_DOWNCAST(class, pointer) 參數 class 類別的名稱。 pointer 要轉換成類別物...
一个用处是DYNAMIC_DOWNCAST,即MFC里实现的对象指针在类层次上的从上到下转换: E.g. ... pCFormView* pView = ... pRenderView* pRenderView = DYNAMIC_DOWNCAST(RenderView, pView) ... 其实现如下: CObject* AFX_CDECL AfxDynamicDownCast(CRuntimeClass* pClass, CObject* pObject) { if (pObject ...
一个用处是DYNAMIC_DOWNCAST,即MFC里实现的对象指针在类层次上的从上到下转换: E.g. ... pCFormView* pView = ... pRenderView* pRenderView = DYNAMIC_DOWNCAST(RenderView, pView) ... 其实现如下: CObject* AFX_CDECL AfxDynamicDownCast(CRuntimeClass* pClass, CObject* pObject) { if (pObject ...
CMFCRibbonColorButton* pColor = DYNAMIC_DOWNCAST(CMFCRibbonColorButton, pRibbon->FindByID(ID_FONT_COLOR));// Get the selected colorreturn pColor->GetColor();}2. 更新 CRibbonAppDoc.cpp 中的事件处理程序函数 CRibbonAppDoc::OnFontColor() 。
CMFCRibbonComboBox* pComboBox = DYNAMIC_DOWNCAST(CMFCRibbonComboBox, m_wndRibbonBar.FindByID(ID_WEBSITES_COMBO)); // 获取Combo Box控件当前选中项的索引 int nCurSel = pComboBox->GetCurSel(); if (nCurSel >= 0) { // 如果索引大于等于0,则说明有选中项,弹出对话框并显示选中项的信息 ...
CDialog* pDlg = DYNAMIC_DOWNCAST(CDialog, CWnd::FromHandlePermanent(hWnd)); if (pDlg != NULL) return pDlg->OnInitDialog(); else return 1; } return 0; } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 由上可以看出,MFC的对话框函数AfxDlgProc仅处理消息WM_INITDIALOG...
创建对话框的类,该类要从CpropertyPage继承;然后在要添加该对话框为属性页的类(头文件)里创建CpropertySheet类的一个对象m_tabsheet和新创建的对话框类的对象m_skatch;最后,在.cpp文件里的OnInitDialog()之类的函数里实现如下代码:m_tabsheet.Create(this, WS_CHILD | WS_VISIBLE, 0);"//使选项卡的按钮在下面...
void CMainFrame::OnWebsitesCombo() { // TODO: Add your command handler code here // 获取Combo Box控件的指针 CMFCRibbonComboBox* pComboBox = DYNAMIC_DOWNCAST(CMFCRibbonComboBox, m_wndRibbonBar.FindByID(ID_WEBSITES_COMBO)); // 获取Combo Box控件当前选中项的索引 int nCurSel = pComboBox->GetCurS...
caseIDR_PANE_VIEW2: { if(!m_pSliceView2) { m_pSliceView2=DYNAMIC_DOWNCAST(CSliceView2, pPane->AttachView(this,RUNTIME_CLASS(CSliceView2))); } else { pPane->Attach(m_pSliceView2->GetParent()); } break; } default: break; } }...