bool CBridgeWindow::CreateNavigationBar(CMFCOutlookBar& bar, UINT uiID, int nInitialWidth, CTreeCtrl& treectrl)
{
//创建导航栏
bar.Create("节点",this,CRect(0, 0, 250, 32000),uiID,WS_CHILD | WS_VISIBLE | CBRS_LEFT);
CMFCOutlookBarTabCtrl* pOutlookBar = (CMFCOutlookBarTabCtrl*)m_navigation.GetUnderlyingWindow();
if (pOutlookBar == NULL)
{
ASSERT(FALSE);
return FALSE;
}
//pOutlookBar->EnableInPlaceEdit(TRUE);//标签能够被编辑
DWORD dwStyle = AFX_CBRS_FLOAT | AFX_CBRS_AUTOHIDE | AFX_CBRS_RESIZE;
CRect rectDummy(0, 0, 0, 0);
const DWORD dwTreeStyle = WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS;
treectrl.Create(dwTreeStyle,rectDummy,&bar,ID_TREELIST);
TVINSERTSTRUCT tvInsert;
tvInsert.hParent = NULL;
tvInsert.hInsertAfter = NULL;
tvInsert.item.mask = TVIF_TEXT;
tvInsert.item.pszText = "河北";
tvInsert.item.lParam=1;
HTREEITEM hBridge = treectrl.InsertItem(&tvInsert);
tvInsert.item.pszText = "山东";
tvInsert.item.lParam=2;
TVINSERTSTRUCT tNode;
//tNode.hInsertAfter=hBridge;
tNode.hParent=hBridge;
tNode.item.mask=TVIF_TEXT;
tNode.item.pszText="石家庄";
tNode.item.lParam=1;
treectrl.InsertItem(&tNode);
hBridge=treectrl.InsertItem(&tvInsert);
treectrl.InsertItem(TVIF_TEXT,"济南", 0, 0, 0, 0, 0, hBridge, NULL);
pOutlookBar->AddControl(&treectrl, "节点列表", 2, TRUE, dwStyle);
return false;
}
|