如何将CMFCPropertyGridCtrl添加到对话框

时间:2013-02-20 11:18:16

标签: visual-c++ mfc mfc-feature-pack

有人能举例说明如何在对话框中添加CMFCPropertyGridCtrl。我试图创建一个对话框并添加一个CMFCPropertyGridCtrl。但它给了我错误。我们非常感谢教程或工作代码。

感谢。

1 个答案:

答案 0 :(得分:0)

最后我学会了添加一个CMFCPropertyGridCtrl。这是代码..

CMFCPropertyGridCtrl m_wndPropList1;
m_wndPropList1.Create( WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, rectPropList1, this, MY_GRID_CTRL_ID);

m_wndPropList1.EnableHeaderCtrl();
//m_wndPropList.EnableDescriptionArea();
m_wndPropList1.SetVSDotNetLook(TRUE);
m_wndPropList1.MarkModifiedProperties(TRUE);
m_wndPropList1.SetAlphabeticMode(!TRUE);
m_wndPropList1.SetShowDragContext(TRUE);

CMFCPropertyGridProperty* pGroupFont = new CMFCPropertyGridProperty(_T("Theme Header Text Properties"));
LOGFONT lf;
CFont* font = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
font->GetLogFont(&lf);
lstrcpy(lf.lfFaceName, _T("Arial"));
COLORREF col = RGB(0 , 0 ,0);
pGroupFont->AddSubItem(new CMFCPropertyGridFontProperty(_T("Header Font"), lf,
    CF_EFFECTS | CF_SCREENFONTS, _T("Specifies the default font for the dialog") , IDC_PROPERTY_GRID1_FONT , col) );

CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("Header Font Color"),
    RGB(0, 0, 0), NULL, _T("Specifies the default dialog font color") , IDC_PROPERTY_GRID1_FONT_COLOR);
pColorProp->EnableOtherButton(_T("Other..."));
pColorProp->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
pGroupFont->AddSubItem(pColorProp);

CMFCPropertyGridColorProperty* pColorProp2 = new CMFCPropertyGridColorProperty(_T("Header Back Color"),
    RGB(255, 255, 255), NULL, _T("Specifies the default dialog background color") , IDC_PROPERTY_GRID1_BACK_COLOR);
pColorProp2->EnableOtherButton(_T("Other..."));
pColorProp2->EnableAutomaticButton(_T("Default"), ::GetSysColor(COLOR_3DFACE));
pGroupFont->AddSubItem(pColorProp2);

m_wndPropList1.AddProperty(pGroupFont);