The use of VC + + tree view Control in multiple documents

Source: Internet
Author: User
Tags bool

Since coming to our forum, we have known a lot of friends and programming experts, from learning a lot of knowledge. I think there are a lot of people in the forum asking questions about tree control. Therefore, the tree control of some of the problems written out for everyone to reference, but also as a recent period of time to learn the summary.

This article focuses on how to add a controlbar to multiple documents and how to add a tree control method to the ControlBar. This is also a software system commonly used in an interface, I hope to be helpful to everyone.

The results of this example are as follows:

First, create a new multiple document project, copy Sizecbar.cpp and Sizecbar.h to the project file Plus, and add new files to the project. A new class of Csizingcontrolbar is added to the project. Then, a new class mybar based on CToolBar is generated using class Wizard. Change the base class to Csizingcontrolbar.

Add OnUpdateCmdUI to the Mybar class (CFrameWnd *ptarget, BOOL Bdisableifnohndler)

The code is as follows:

void mybar::OnUpdateCmdUI(CFrameWnd *pTarget, BOOL bDisableIfNoHndler)
{
   UpdateDialogControls(pTarget, bDisableIfNoHndler);
}

Add the mybar member variable M_ctrlbar to the CMainFrame and add the code to the CMainFrame oncreate function:

if(!m_CtrlBar.Create("数据浏览条",this, CSize(200,200),TRUE,123))
{
   TRACE0("Failed to create mybar\n");
   return -1;
   // fail to create
}
m_CtrlBar.SetBarStyle(m_CtrlBar.GetBarStyle()|
   CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_CtrlBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_CtrlBar,AFX_IDW_DOCKBAR_LEFT);

Run the program at this point and you will see that the mybar has been added to the project. The following will add a tree-view control to the mybar.

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.