PropertyTree control

PropertyTree control

This article was submitted .

After restructuring my WTL PropertyList control to allow the inline editor controls to operate independantly, I tweaked out this little control.
It looks a bit like the Internet Explorer Option dialog control.

It can use several in-place editors, such as dropdown lists and filename browsers. They are all standard windows, which link to the parent control through a generic interface and some shared window messages.
Because of this, you may extend the control with your own property types. They can be owner-drawn or contain your own popup dialogs.

The control is a subclassed TreeView control.

How to use it

Place a tree control on a dialog.
Add a member variable to your dialog class...
CPropertyTreeCtrl m_Tree
In the OnInitDialog() event handler, add the following line:
LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPA...
Then add the following reflection macro to your main message map:

Here are some of the control methods available:
and most of the original CTreeViewCtrl methods still work as well.

So, set some control flags...

And remember to add an ImageList to the control.
Adding a property requires using a "creation helper" method...
m_Tree.InsertItem( PropCreateReadOnlyItem("Appearance"), 8, 8, TVI_ROOT );
m_Tree.InsertItem( PropCreateCheckmark("AAA"), 0, 0, hItem );
m_Tree.InsertItem( PropCreateOptionCheck("BBB", true), 0, 0, hItem );
Many of the arguments in the InsertItem() are the same as for the standard tree control, but you use the creation helper method to pass the control type.
The last few arguments describe the images to use, and the position where to insert the new item. For the checkmark and option property, the two image arguments are ignored. You may also associate some item-data to each property, so it can later be identified.
The PropertyList control sample explains how to add and use some of the other editors.

Several notifications are sent back to the owner window. They contain information about the property changing using WM_NOTIFY notification structure: NMPROPERTYITEM. The list of notifications currently include:

In addition, all of the original TreeView notifications are also available.

The sample includes a bitmap, which contains the icons for the checkmark and option box. These controls are fixed to this bitmap layout.

Source Code Dependencies

Microsoft Visual C++ 6.0
Microsoft WTL 3.1 Library

See Also

My Property List control
My Property Grid control

Download Files

DownloadSource Code and sample (30 Kb)

To the top