A generic Tree Property Sheet control

Sunday Jul 25th 1999 by Alexander Berthold

A generic Tree Property Sheet control


This class implements a generic tree property control (see picture above).

Its features are:
- Supports variable width tree control
- Autosizing depending on the size of the dialogs contained
- As this version is now based upon the CPropertySheet/ CPropertyPage model, all features of these are available.
- Various styles(for example, like Netscape Communicator's property sheet)
- Extensibility: Allows to integrate user defined controls (like buttons or static text boxes) and easily position them.
- Now supports modeless property sheets as well.

How to implement a CTreePropertySheet in your application:

Step 1.
    Insert "TreePropertySheet.cpp" to your application.
Step 2.
    Insert an

    #include "TreePropertySheet.h"

    in the class implementation file in which you want to use the CTreePropertySheet.
Step 3.
    Define a function which invokes the property sheet, for example:
    void CMyView::OnPropertySheet()
    	// TODO: ...
Step 4.
    Create a CTreePropertySheet object in the handler and the property pages you want to use with CTreePropertySheet:
    CTreePropertySheet tpsSheet;
    CGeneralPrefsPage cGeneralPrefs;
    COtherPrefsPage cOtherPrefs;
    // All dialogs contained in the property sheet must (now) be allocated from the stack.

    Caution: To make it work, the dialogs you want to include must have the following style:
    - Style: 'Child'
    - Border: None
    - Caption: Yes
    - Set the caption to the text you wish to appear when the page is selected.
    - All other options must be unchecked.

Step 5.
    Add the dialogs to the tree property sheet:
    You have to specify the resource ID when adding the dialog. The text argument is the title shown up in the tree control, 'tps_item_node' tells that this is a simple node in the tree.
    (See below for more information)
Step 6.
    Start the property sheet:
    int nRetCode=tpsSheet.DoModal();
    Optionally, you can set a special pre-defined style before DoModal():
    int nRetCode=tpsSheet.DoModal();


To set up the tree structure, there are three different attributes for 'AddPage()':

tps_item_branch This item has sub-items. All following items are one level below this item, until a 'tps_item_endbranch' is found.
tps_item_node This item is a simple node in the tree.
tps_item_endbranch This item is the last item of the current sub-branch(which was initiated with an tps_item_branch). All following items are on the same level as the corresponding 'tps_item_branch' entry.

To make it clearer, please take a look at the table below:

(tree control contents) (code)
+ Main preferences AddPage(tps_item_branch, &cMainPrefsPage);
    - Directories AddPage(tps_item_node, &cDirectoriesPage);
    - User information AddPage(tps_item_node, &cUserPage);
    - Plugins AddPage(tps_item_endbranch, &cPluginPage);
- Security AddPage(tps_item_node, &cSecurityPage);

If you want to enhance the CTreePropertySheet by own controls or buttons, this can be done using InsertExtraControl() / InsertExtraSpace().
For more information about these functions, please take a look into the HTML help file(see below) and into the example project.


Download help file - 29 KB

Download demo project - 52 KB

Download source - 14 KB

These files can also be downloaded at http://members.xoom.com/softserv/tps_index.html

Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved