Can someone give me an example for adding a CMFCPropertyGridCtrl
to a Dialog. I tried to create a dialog and add a CMFCPropertyGridCtrl
. But it gives me errors. A tutorial or a working code is highly appreciated.
Thanks.
Finally I learned to add a CMFCPropertyGridCtrl
. Here is the code..
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);