The CExtTreeCtrl
control is not a simply repainted version of the CTreeCtrl
control. The CExtTreeCtrl
control provides extended features like controls attached to each tree item, multiple item selection, disabled items, checked and radio-checked tree items. The check boxes of the CExtTreeCtrl
control are not based on the check boxes of the CTreeCtrl
control. The CExtTreeCtrl
control supports per-tree-item optional check boxes. Both two-state and tree-state checkboxes are supported. You can see this on the Tree View dialog page in the ProfUIS_Controls sample application. Here is how the check boxes initialized in the CPageTreeCtrl::OnInitDialog()
method in this sample application:
hti = m_wndTree.InsertItem( _T("Two-state check box"), htiCheckBoxes, NULL );
m_wndTree.TreeItemInfoGet( hti ).m_eCheckBoxType = CExtTreeCtrl::e_cbt_check_box;
hti = m_wndTree.InsertItem( _T("Three-state check box"), htiCheckBoxes, NULL );
m_wndTree.TreeItemInfoGet( hti ).m_eCheckBoxType = CExtTreeCtrl::e_cbt_tri_state_check_box;
The check box state is stored in the
CExtTreeCtrl::TREEITEMINFO_t::m_nCheckBoxState
property. You can access the
CExtTreeCtrl::TREEITEMINFO_t
data structure describing extended tree item using the
CExtTreeCtrl::TreeItemInfoGet()
method.
The check box state changing event does not have a dedicated messages and virtual methods. Please override the
CExtTreeCtrl::OnTreeMouseClick()
virtual method and add the
OnKeyDown()
handler method for the
WM_KEYDOWN
message into your
CExtTreeCtrl
-derived class. Your methods should remember the checked state of a tree item, invoke the parent class method and analyze the new checked state of the same tree item.