MFC右侧属性分栏用法
初始状态设置
m_wndPropList.EnableHeaderCtrl(FALSE);
m_wndPropList.EnableDescriptionArea();
m_wndPropList.SetVSDotNetLook();
m_wndPropList.MarkModifiedProperties();
添加分栏:
CMFCPropertyGridProperty* pGroup1 = new CMFCPropertyGridProperty(_T("外观"));
m_wndPropList.AddProperty(pGroup1);
添加子项:
pGroup1->AddSubItem(new CMFCPropertyGridProperty(_T("三维外观"), (_variant_t) false, _T("指定窗口的字体不使用粗体,并且控件将使用三维边框")));
添加带有下拉菜单的子项
CMFCPropertyGridProperty* pProp
= new CMFCPropertyGridProperty(
_T("边框")/*标题*/,
_T("对话框外框")/*初始条件*/,
_T("其中之一:“无”、“细”、“可调整大小”或“对话框外框”")/*提示内容*/);
pProp->AddOption(_T("无"));//下拉菜单
pProp->AddOption(_T("细"));
pProp->AddOption(_T("可调整大小"));
pProp->AddOption(_T("对话框外框"));
pProp->AllowEdit(FALSE);
pGroup1->AddSubItem(pProp);
字体设置
pGroup2->AddSubItem(new CMFCPropertyGridFontProperty(_T("字体"), lf, CF_EFFECTS | CF_SCREENFONTS, _T("指定窗口的默认字体")));
颜色设置
CMFCPropertyGridColorProperty* pColorProp = new CMFCPropertyGridColorProperty(_T("窗口颜色"), RGB(210, 192, 254), NULL, _T("指定默认的窗口颜色"));
文件夹设置
pGroup3->AddSubItem(new CMFCPropertyGridFileProperty(_T("文件夹"), _T("c://")));
层次结构
m_wndPropList.AddProperty(pGroup3);
CMFCPropertyGridProperty* pGroup4 = new CMFCPropertyGridProperty(_T("层次结构"));
CMFCPropertyGridProperty* pGroup41 = new CMFCPropertyGridProperty(_T("第一个子级"));
pGroup4->AddSubItem(pGroup41);
CMFCPropertyGridProperty* pGroup411 = new CMFCPropertyGridProperty(_T("第二个子级"));
pGroup41->AddSubItem(pGroup411);
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 1"), (_variant_t) _T("值 1"), _T("此为说明")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 2"), (_variant_t) _T("值 2"), _T("此为说明")));
pGroup411->AddSubItem(new CMFCPropertyGridProperty(_T("项 3"), (_variant_t) _T("值 3"), _T("此为说明")));
pGroup4->Expand(FALSE);