我的小软件的主界面是这样的
左边是界面导航条,选择左边的选项,右边的界面会切换
左边用一个CTreeView实现
右边用不同的CFormView实现
如图:

(图1)
(图2)
实现这个功能,我们首先要静态拆分窗口,这个前面已经介绍过了
插入一个CMyTreeView类
重载下面三个成员函数:
void
CMyTreeView::OnInitialUpdate()

...
{
CTreeView::OnInitialUpdate();

//获得TreeView的CTreeCtrl控件句柄
m_hTree = &GetTreeCtrl();

HTREEITEM hRoot = m_hTree->InsertItem(_T("界面选择"), TVI_ROOT);

HTREEITEM hNormal = m_hTree->InsertItem(_T("日历模式"), hRoot);
HTREEITEM hdata = m_hTree->InsertItem(_T("记录模式"), hRoot);
HTREEITEM hStatistic = m_hTree->InsertItem(_T("统计模式"), hRoot);

CTime time = CTime::GetCurrentTime();
CString currentMonth, firstMonth, secondMonth;
currentMonth.Format("%d月记录",time.GetMonth());
firstMonth.Format("%d月记录",(time.GetMonth()-1)%12);
secondMonth.Format("%d月记录",(time.GetMonth()-2)%12);
m_hTree->InsertItem(currentMonth, hdata);
m_hTree->InsertItem(firstMonth, hdata);