0

有人可以给我一个将 CMFCPropertyGridCtrl 添加到对话框的示例。我试图创建一个对话框并添加一个 CMFCPropertyGridCtrl。但它给了我错误。非常感谢教程或工作代码。

谢谢。

4

1 回答 1

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);
于 2013-03-13T10:09:18.297 回答