(1) MFC下的多列表视图
在VS2010下,提供了类CMFCPropertySheet和CMFCPropertyPage进行列表视图和相关页面的加载,首先构造基于CMFCPropertyPage的页面类,建立对话框资源,将模式设置为“Child”,然后建立以CPropertyPage为基类的CPage1,将基类更换为CMFCPropertyPage,重载虚函数OnInitDialog(),以同样的方法建立CPage2,…,CPage5。然后建立以CPropertySheet为基类的类建立CControlSheet,再将基类更换为CMFCPropertySheet,重载构造函数和初始化函数,并在其中增加CPage1,…,CPage5类型的变量m_page1,…,m_page5,
CControlSheet::CControlSheet(CWnd*pParentWnd)
:CMFCPropertySheet(IDS_CONTROL,pParentWnd)
{
BOOL b32BitIcons = TRUE;
SetLook(CMFCPropertySheet::PropSheetLook_OutlookBar); //设置外观
SetIconsList(b32BitIcons ? IDB_ICONS32 :IDB_ICONS, 32); //设置图标
AddPage(&m_page1);
AddPage(&m_page2);
}
为了增强界面显示,在应用函数中增加显示风格控制:
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
CMFCButton::EnableWindowsTheming();
更改应用程序类的初始化代码,调用CControlSheet作为主界面
CControlSheet*pPropSheet = new CControlSheet;
m_pMainWnd= pPropSheet;
pPropSheet->DoModal();
delete pPropSheet;
实现的界面为: