Solved

Disable few seleceted items in CTreeCtrl

Posted on 2011-09-23
5
1,444 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 264
Programatically extract date from website 8 89
Not seen Link button 5 76
Please explain purpose of GZIP 4 82
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

737 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