TreeView Control
The treeview control displays information in a hierarchical form - showing parent-child relationships between data items. Parent structures can be closed or expanded to minimize the space needed to display and entire "tree", as the structure is called.

Arguments
The Control Add statement is used to create all new controls. Here are the statement's arguments and any special significance to the treeview control.

Usage Notes
Some of these comments refer to the TreeView-specific statement in the next section below.

Indexing is starts at 1 for all Control and listview statements.

TreeView-Specific PowerBASIC Statements
PowerBASIC provides several statements specific to the treeview control. These allow the application to manage the content and display of the control.

Here's a summary of the TreeView statements, categorized by the capability they provide.

And here's a description and syntax for each of the TreeView statements, along with some additional usage information.

And here is a short description of the arguments used in the TREEVIEW statements.

See the Usage section above for information on how to use the values made available by these statements.

Messages, Notifications, Styles, and ExtSstyles
There are four types of named constants in the following table. All are pulled from the MSDN web site.

The first column contains control-specific named constants and the second column contains generic window named constants (treeview controls are windows).

Also, if the PowerBASIC Help file has an entry on the value, it is highlighted in yellow. If the value was noted in PowerBASIC Help as a default value, it is also shown in bold text.

In the values for notifications, descriptions starting with -n and -c refer to events received through the %wm_notify and %wm_command messages. By default, PowerBASIC controls can receive both of these messages.

   

And here is a short description of many of the named constants corresponding to notifications, styles, and extstyle - particularly those discussed in the PowerBASIC Help topics.



Callback Function
A control can have its own callback function, or use the parent dialog callback function.

A control callback function should return TRUE to indicate it has processed the message. This prevents unnecessarily calling the dialog callback function, which will process the message if no control callback function is available, or if the control callback function returns FALSE.

By default, both %WM_COMMAND and %WM_NOTIFY messages are received. However, if the #MESSAGE COMMAND compiler directive is invoked, the %WM_NOTIFY messages will not be available.

Here's a sample treeview control callback function.

   CallBack Function cbTreeView()
      Select Case CB.MSG
         Case %WM_COMMAND
            Select Case CB.CTLMSG
               Case %nm_click
               Case %nm_dblclk
               Case %nm_killfocus
               Case %nm_rclick
               Case %nm_rdblclk
               Case %nm_return
               Case %nm_setfocus
               Case %tvn_beginlabeledit
               Case %tvn_deleteitem
               Case %tvn_endlabeledit
               Case %tvn_itemchanged
               Case %tvn_itemchanging
               Case %tvn_itemexpanded
               Case %tvn_itemexpanding
               Case %tvn_keydown
               Case %tvn_selchanged
               Case %tvn_selchanging
               Case %tvn_singleexpand
         End Select
      End Select
   End Function

In each Case section, add the statements the application needs to respond to the event. Also, be sure to add "Function=1" as appropriate to indicate that the event was handled by the callback function.

Issues
The TreeView Insert Item statement does not recognize the command to show no images (value 0 for image&).

I'll update this page as more information becomes available.

CONTROL Statement Syntax
The following table lists the various Control statements (except the ADD statements). Most, but not all, can be used with the treeview control. A one-line description of the statement and then its syntax are presented.

If you have any suggestions or corrections, please let me know.