I have search开发者_开发百科ed through internet & found that there are no any direct method that disable nodes of CTreeCtrl control.
check one post at http://www.ucancode.net/faq/MFC_CTreeCtrl-CListCtrl.htm & also on codeguru.com but not clear about how to disable node of CTreeCtrl.
Well, I think, the article you linked, speaks the truth: It's not possible (at least not for Windows versions before Vista, see below). You have to program the workarounds recommended in the link to "simulate" item disabling. It means: Give the item a specific colour (light grey for instance) and catch all the events which can occur on a TreeView item and cancel the actions (like expanding/collapsing a node, and so on).
Here, http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/3350ba1e-1fcf-47fe-ab6b-e20c6b5afd91, the statement of the article is more or less confirmed by Microsoft experts. They recommend the same workaround (and actually link to the same article). Also note the link to http://www.codeproject.com/KB/tree/colortreectrl.aspx on how to change individual item colors which might help if you really want to start programming the workaround.
"More or less confirmed" means: There seems to be an exception for Vista and higher:
"CTreeCtrl::SetItemStateEx() supports TVIS_EX_DISABLED (described in TVITEMEX structure) style which disables treectrl node. But its only supported from Vista onwards."
I've seen that sometimes it is talked about a possible value TVIS_DISABLED
of the state flag of the TVITEM structure and actually the MSDN of the old VC6 compiler contains a technical article (from 1994 before release of Windows 95 ;)) which says that such a state value should exist with the meaning: "The item is disabled and is drawn using the standard disabled style and color."
This article was preliminary ("Please note that this article is based on preliminary information that is subject to change before the final version of Windows 95."
) and obviously this value for item disabling did not make its way into the final release of Windows95 as you cannot find it in any VC header files.
So either you can make sure that your program is only used on Vista or higher computers (then it's probably easy with the extended state flag above) or it will be an ugly work (though doable and not necessarily very difficult).
精彩评论