When the underlying framework is set up, I want to add a left navigation bar for it, as follows:
Add a navigation bar parameter to the header file of the Framework class:
CMFCOutlookBar m_navigation;
|
In order to improve the function, I added a CTreeCtrl control in the navigation bar.
and create a function to create the navigation bar, and associate the CTreeCtrl control with the function prototype as follows:
tbody>
bool createnavigationbar (Cmfcoutlookbar& bar< Span style= "color: #0000cc;" >, UINT uiidint ninitialwidth & Treectrl ) |
uiID forCMFCOutlookBar的ID,
nInitialWidth为导航栏的宽度,函数的实现如下
bool CBridgeWindow::CreateNavigationBar(CMFCOutlookBar& bar, UINT uiID, int nInitialWidth, CTreeCtrl& treectrl) {
Create a navigation bar Bar. Create(Node,This, CRect(0, 0, 250, 32000), UiID, Ws_child| Ws_visible| Cbrs_left); CMFCOutlookBarTabCtrl* Poutlookbar=(CMFCOutlookBarTabCtrl*) m_navigation. Getunderlyingwindow();
If(Poutlookbar==Null) { Assert(FALSE); ReturnFALSE; } Poutlookbar->enableinplaceedit (TRUE);//tags can be edited
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=Hebei; Tvinsert. Item. LParam=1; Htreeitem Hbridge= Treectrl. InsertItem(&tvinsert); Tvinsert. Item. pszText=Shandong; Tvinsert. Item. LParam=2; Tvinsertstruct Tnode; Tnode.hinsertafter=hbridge;
Tnode. hparent=hbridge; Tnode. Item. Mask=tvif_text; Tnode. Item. pszText=Shijiazhuang; Tnode. Item. LParam=1; Treectrl. InsertItem(&tnode) hbridge=treectrl (&tvinsert ) treectrl (Tvif_text Jinan " 0 0, 0 0 Hbridge, null
pOutlookBar->AddControl(&treectrl, "节点列表", 2, TRUE, dwStyle); return false; }
|
Calling code
int Cbridgewindow:: OnCreate(Lpcreatestruct lpcreatestruct) { If(CFrameWndEx:: OnCreate(lpcreatestruct)==-1) Return-1; CMFCVisualManagerOffice2007:: SetStyle(CMFCVisualManagerOffice2007:: Office2007_lunablue); CMFCVisualManager:: SetDefaultManager(Runtime_class(CMFCVisualManagerOffice2007)); CDockingManager:: SetDockingMode(Dt_smart); M_wndribbonbar. Setwindows7look(False); RedrawWindow(Null,Null, Rdw_allchildren| Rdw_invalidate| Rdw_updatenow| Rdw_frame| Rdw_erase); M_wndribbonbar. Create(This); M_wndribbonbar. LoadFromResource(Idr_ribbon); Enable Visual Studio 2005 Style Docking window behavior Cdockingmanager::setdockingmode (Dt_smart); //enable Visual Studio 2005 Style Docking Window Auto-hide behavior // enableautohidepanes (Cbrs_align_any); //Create left navigation bar Createnavigationbar (M_navigation,id_navigation< Span style= "color: #0000cc;" >,250,m_treectrl) return 0 /span>
|
Of course, to add the resource ID in resource.h:ID_NAVIGATION,
ID_TREELIST,编译运行即可
Source text: http://blog.chinaunix.net/uid-24585655-id-2125546.html
MFC office2007 Style Set left navigation bar [go]