MFC office2007 Style Set left navigation bar [go]

Source: Internet
Author: User

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.

CTreeCtrl m_treectrl;

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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.