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.