Link to home
Start Free TrialLog in
Avatar of RsTVS
RsTVSFlag for India

asked on

Disable few seleceted items in CTreeCtrl

Hi, can you please tell how we can disable few CTreeCtrl items and few of them enable.
I shouldnt be able to perform any action on those disabled items, i shouldnt be able to check it's check box, i shouldnt be able to edit those items too.

I do not want to use this function:      
SetItemStateEx(l_hTempItem, TVIS_EX_DISABLED);


Regards and thanks for the help
 
ASKER CERTIFIED SOLUTION
Avatar of mrwad99
mrwad99
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RsTVS

ASKER

Is there any other way of doing it other than storing the list of items to be disabled. something like setting the state of HTREEITEM, by setting some flags in SetItemState(),

The checkboxes are not actual checkboxes, but are in fact images from an image list; you can prove this by using Spy++ on a tree control with checkboxes.  Therefore, there is no "control" as such to "disable".  Your best bet is to create the illusion of a "disabled" checkbox, by perhaps using a three-state-checkbox tree control, like this one:

http://www.codeguru.com/cpp/controls/treeview/misc-advanced/article.php/c3983/TreeView-with-Three-State-Checkboxes.htm

You still need to keep a list of the items to disable though, so can programatically alter the image being shown to the "disabled" one.

HTH
Oh, and to prevent the editing of the label text, you need to trap TVN_ITEMCHANGING, and return TRUE to prevent the edit from being initiated.  But again, you still need to keep a list of the items you don't want to be edited.
Avatar of RsTVS

ASKER

I have tried this method of keeping a list of HTREEITEMS and over rided ON_WM_LBUTTONDOWN, i have omitted defalut handling of lbutton down of CTreeCtrl for all the tree items which i want to be disabled,


Thanks for the help anyway.