Solved

Disable few seleceted items in CTreeCtrl

Posted on 2011-09-23
5
1,423 Views
Last Modified: 2012-05-12
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
 
0
Comment
Question by:RsTVS
  • 3
  • 2
5 Comments
 
LVL 19

Accepted Solution

by:
mrwad99 earned 500 total points
ID: 36598281
You could keep a list of the HTREEITEMs that you wish to "disable"; then, whenever the user clicks on the tree control, you get the item that was clicked on, comparing it to the items in your list.  If the item exists in the list, then you prevent the click from going through.

I believe the function you want is OnNMClicked or similar...
0
 

Author Comment

by:RsTVS
ID: 36598385
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(),

0
 
LVL 19

Expert Comment

by:mrwad99
ID: 36598449
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
0
 
LVL 19

Expert Comment

by:mrwad99
ID: 36598467
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.
0
 

Author Closing Comment

by:RsTVS
ID: 36598622
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.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question