Sometimes you don't need a tree control all nodes display a check box, and then you need to hide the checkbox for the corresponding node, the code reads as follows:
M_treecontrol is the CTreeCtrl variable associated with the tree control, Nrootitem is the root node defined by Htreeitem;
M_treecontrol.setitemstate (nrootitem,indextostateimagemask (0), tvis_stateimagemask);//Hide root node check box
If you need to hide the checkbox of a node in the OnInitDialog () function of a class, you need to add the following two lines of code before the above code to take effect, otherwise it will not work:
Magic two lines of code
m_treecontrol.modifystyle (tvs_checkboxes, 0);
M_treecontrol.modifystyle (0, tvs_checkboxes);
M_treecontrol.setitemstate (nrootitem,indextostateimagemask (0), tvis_stateimagemask);//Hide root node check box
The following figure is a picture of the check boxes for the first to second and three layers of a tree that I hide.