Introduction

The CPropTree class implements a tree control that is similar to the property
view seen in Visual Studio .Net. The source project compiles to a DLL so you can easily incorporate
it into your project. You can check my web page for more information
on the control.

The control has two window areas:

Tree Control

Descriptive area

The tree control section functions just a like a normal tree control with an addition of a
splitter bar separating the tree item properties. Tree item properties are inherited from
the CPropTreeItem class. These items can be edit controls, static text, dropdown
combo list, or any type of control you wish to create. Items on the root level of the tree
control do not have editable properties. They are used as section headers.

Tree items can contain checkboxes. By default properties that are editable (non-readonly), are displayed in
bold lettering. Read only or non-editable items are displayed in a normal font.

The descriptive area displays the selected item's text and any informational text. This section can
be displayed or hidden by calling CPropTree::ShowInfoText().

Implementation

To use the control, create an instance of the class in your dialog or view class header. In
the OnInitDialog() or OnCreate() initialize the control:

Advanced Features

Notification Messages

The control uses WM_NOTIFY notification messages to signal events. Add a ON_NOTIFY
message handler to the parent window to process notifications. The control supports
most of the common NM_ codes with addition of the following CPropTree specific WM_NOTIFY codes.

PTN_INSERTITEM when an item is inserted

PTN_DELETEITEM when an item is about to be deleted

PTN_DELETEALLITEMS when a call is made to delete all items

PTN_ITEMCHANGED when an item's property has been modified

PTN_SELCHANGE when the current selection changed

PTN_ITEMEXPANDING when an item is about to expand or close

PTN_COLUMNCLICK when the mouse clicks on the splitter bar

PTN_PROPCLICK when the mouse clicks on an item's property area

PTN_CHECKCLICK when the mouse clicks on an item's checkbox

PTN_ notification messages returns the NMPROPTREE structure. You can use this structure along with the
CPropTreeItem::SetCtrlID() method to determine the tree item that sent an event.

Dynamically create an instance of your class and insert it into a CPropTree control.

The methods most often overriden from CPropTreeItem are:

CPropTreeItem::OnActivate(). Called when the property area is clicked by the mouse
or the enter key has been pressed on the selected item. The OnActivate() method is where you
show the property item's window if it has one (such as an edit control or a popup menu).

CPropTreeItem::OnCommit(). Called when data has been commited. In this method you would extract
the changed data and hide the property's item's window. OnCommit() gets called when CommitChanges()
is called. A derived CPropTreeItem class would call CommitChanges() during a loss of the input
focus or if the "Enter" key is press as in a edit control.

CPropTreeItem::DrawAttribute(). CPropTree calls DrawAttribute() when
the property item needs to be displayed. Drawing is done directly on the display context of the PropTree control.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

1. I notice the stringtable combo entries. How would you support translations into other languages? it would look odd some of my languages having english wording. i use resource only dll files for my app interface. just wondered how you would deal with it.

Currently, I'm passing a pointer into CPropTreeItem::SetCtrlID(). The problem is that function takes a UINT argument, which is 32-bit even in a 64-bit compiler (if my understanding is correct). So Visual Studio 2003 (with SP1) is giving me C4311 pointer truncation warnings.

I want to use a special CTreeCtrl placed on the
right side of my application. And I hope the root
node of the tree can be placed on the right side
and all the subtreeitem on the left side.
If any one can help me?
my email: wjg1979@hotmail.com

I want to have a check box before each root level of the property tree and allow the user to delete the root level items( and the corresponding sub level items in that root level).So far I could get to the point where I could identify which root level item's check boxes are checked. Now I have to delete these checked root levels. Can some one help me on how to do this??

What can you do with it? How can you check it's variable type? How to cast it to a color, string, number or whatever?

Maybe this is too basic, but the documentation is very limited. It doesn't really show how to handle the modified data. I've noticed this control is almost abandoned, but I got it to work just fine, so it would be nice to be able to really use it.

I've been looking for an easy way to list an unlimited number of combo
boxes, and your CPropTree class looks like the best way to do it.
Unfortunately, I'm having problems adding it to my MSVC++ .Net 2003 project.
I changed my CTreeCtrl class to CPropTree, included PropTree.h, and put the
following code in my InitDialog:
CPropTreeItem* pRoot;
pRoot = PropTree.InsertItem(new CPropTreeItem());
pRoot->SetLabelText("Properties");
pRoot->SetInfoText("This is a root level item");
pRoot->Expand(); // have this item expanded by default