1. Create a control over the control bar // Take the tree control as an example // Create a custom control bar if (! M_wndmybar.create (_T ("My Control Bar"), THIS, 123)) {Trace0 ("failed) to create mybar / n "); return -1;} m_wndMyBar.SetBarStyle (m_wndMyBar.GetBarStyle () | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);! / this piece of code to create a tree view control if (m_Tree.Create (WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESTROOT, CRECT (0, 0, 0, 0), & M_Wndmybar, 100)) {Trace0 ("Failed to Create Instant Bar Child / N); Return -1;} m_tree.modifyStyleex (0, WS_EX_CLIENTEDGE); 2. Creating a control over the toolbar // First, CSTATIC and CEDIT are first named ID_text and id_edit in the resource editor for the resource editor, and then named ID_text and id_edit, and then add in the main frame mainframe.h file The #define id_edt wm_user 1000 # define id_txt ID_EDT 1000 then adds the following code // get the following code INDEX = 0 in the mAINFRAME.CPP on the oncreate function in mainframe.cpp; Rect Rect; while (m_wndtoolbar.getItemid (INDEX)! = ID_TEXT) INDEX ; set the width of the specified tool item and get the new area 80 is the width m_wndtoolbar.setButTonInfo (INDEX, ID_TEXT, TBBS_SEPARATOR, 80); // Setting position m_wndtoolbar.GetItemRect (INDEX, & Rect); Rect.Top = 5; Rect.Bottom = 50; if (! m_static.create "(" Enter Name: ", SS_LEFT, RECT, & M_WNDTOOLBAR, ID_TXT)) {Trace0 (" Failed to Create Toolbar / N "); return -1; // fail to create} cfont * font = m_wndtoolbar.getfont (); m_static.setfont (font); m_static.showwindow (sw_show); // Get position index = 0; Rect; while ! m_wndToolBar.GetItemID (index) = ID_EDIT) index ; Specifies the width of the tool set of items and obtain a new region 80 width m_wndToolBar.SetButtonInfo (index, ID_EDIT, TBBS_SEPARATOR, 100); // set position m_wndToolBar.GetItemRect (index, & rect Rect.top = 1;
// Rect.bottom; if (! m_edit.create (es_left, reference, & m_wndtoolbar, id_edt)) {trace0 ("failed to create toolbar / n"); return -1; // fail to create} m_edit.setfont (this -> getFont ()); m_edit.showwindow (sw_show); in the toolbar, a CSTATIC and CEDIT control 3. An example of the icon of the tree control node (Tree control definition problem 1) First declare a CImageList M_ImageListTree ; Then // Initialize the icon IF of the tree control (! M_imagelisttree.create (idb_file_types, 17, 1, rgb (255, 255))); _t ("Image List Creation Fault"); m_tree.setimagelist & m_imagelisttree, TVSIL_NORMAL); Add content to tree controls /// m_hroot = m_tree.insertitem (_T ("shared contact"), 1, 0); 4. The node of the tree control has two stored properties (1 ). Node's text --- Storage node displayed text (2). Node's DATA --- Storage node's unique identifier, such as files, etc. 5. Document template and document template manager CWINAPP objects generally contain m_pdocmanager Attribute, the document manager. By pApp-> m_pDocManager-> GetFirstDocTemplatePosition (); CProjectTemplate * pTemplate;; CProjectDoc * pDoc; CWinApp * pApp = AfxGetApp (); // traverse the document template, locate the extension phase through the document template examples POSITION pos; CString m_sDocString corresponding template pos = pApp-> m_pDocManager-> GetFirstDocTemplatePosition (); while (pos) {pTemplate = (CProjectTemplate *) pApp-> GetNextDocTemplate (pos); m_sDocString = pTemplate-> GetDocStrings (); // find the corresponding template Call the OpenDocumentFile function creation document IF ("m_sdocstring.find (". Doc ", 0)! = - 1 && b_docFind == false) {pdoc = (cprojectdoc *) PTEMPLATE-> OpenDocumentFile (null); // Create a document OnSavadocument stores documents and creates files pdoc-> onsavedocument (filepath);}} All need to include sizecbar.cpp, sizecbar.h, scbarg.h, scbarg.cpp file, detailed information about these four files can be searched ~~ Mainly some of the interface-friendly controls