Tree-view control help

Function help:

Real API_Treeview_Create (Real Parent Handle, Real X, Real Y, Real Width, Real Height, Real Style Flags, Real Extended Style Flags);

This function creates a new tree-view control.

Argument list:
(0) Parent Handle: Identifies the window handle of the window to create this control on.
(1) X: The horizontal position of the control in pixels, relative to the parent window.
(2) Y: The vertical position of the control in pixels, relative to the parent window.
(3) Width: The horizontal size of the control in pixels.
(4) Height: The vertical size of the control in pixels.
(5) Style Flags: The style flags, supports the Global Control Styles and the following styles:

TVS_CHECKBOXES
Enables check boxes for items in a tree-view control. A check box is displayed only if an image is associated with the item. State image 1 is the unchecked box and state image 2 is the checked box. Setting the state image to zero removes the check box altogether.
Displays a check box even if no image is associated with the item.
Once a tree-view control is created with this style, the style cannot be removed. Instead, you must destroy the control and create a new one in its place. Destroying the tree-view control does not destroy the check box state image list. You must destroy it explicitly.

TVS_EDITLABELS
Allows the user to edit the labels of tree-view items.

TVS_FULLROWSELECT
Enables full-row selection in the tree view. The entire row of the selected item is highlighted, and clicking anywhere on an item's row causes it to be selected. This style cannot be used in conjunction with the TVS_HASLINES style.

TVS_HASBUTTONS
Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent item's list of child items. To include buttons with items at the root of the tree view, TVS_LINESATROOT must also be specified.

TVS_HASLINES
Uses lines to show the hierarchy of items.

TVS_LINESATROOT
Uses lines to link items at the root of the tree-view control. This value is ignored if TVS_HASLINES is not also specified.

TVS_NOHSCROLL
Disables horizontal scrolling in the control. The control will not display any horizontal scroll bars.

TVS_NOSCROLL
Disables both horizontal and vertical scrolling in the control. The control will not display any scroll bars.

TVS_RTLREADING
Causes text to be displayed from right-to-left (RTL). Usually, windows display text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic that read RTL. Typically, tree-view text is displayed in the same direction as the text in its parent window. If TVS_RTLREADING is set, tree-view text reads in the opposite direction from the text in the parent window.

TVS_SHOWSELALWAYS
Causes a selected item to remain selected when the tree-view control loses focus.

TVS_SINGLEEXPAND
Causes the item being selected to expand and the item being unselected to collapse upon selection in the tree view. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the user holds down the CTRL key while selecting an item, the item being unselected will not be collapsed.

Causes the item being selected to expand and the item being unselected to collapse upon selection in the tree view. If the user holds down the CTRL key while selecting an item, the item being unselected will not be collapsed.

TVS_TRACKSELECT
Enables hot tracking in a tree-view control.

Sorts strings in the list box alphabetically. The parent window receives an input message whenever the user clicks or double-clicks a string. The list box has borders on all sides.

Style flags can be separated by a bitwise or '|' operator.

(6) Extended Style Flags: This can be any combination of the Global Extended Control Styles.

Return value:
If this function succeeds, it returns the Control ID of the control, otherwise it returns 0.


Real API_Treeview_DeleteAllItems ( Real Control ID)

This function removes all items from a tree-view control.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Treeview_DeleteItem ( Real Control ID, Real Item Handle)

This function removes an item from a tree-view control.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Treeview_Expand ( Real Control ID, Real Item Handle, Real Expand Item)

This function expands a tree-view item. (It turns [-] into [+] )

Set argument2 (Expand Item) to 1 to expand, or set it to 0 to collapse.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Treeview_GetBkColor ( Real Control ID )

This function returns the background color of a tree-view control.

Return value:
Returns a color value that represents the current background color. If this value is -1, the control is using the system color for the background color.
Real API_Treeview_GetCheckState ( Real Control ID , Real Item Handle)

This function returns the check state of a tree-view item.

Return value:
1:
Checked
0: Unchecked
-1: No Check Box Image
Real API_Treeview_GetCount ( Real Control ID)

Returns the count of items in a tree-view control.

Return value:
Returns the count of items.

Real API_Treeview_GetEditControl ( Real Control ID)

Returns the window handle of the edit control assigned to the tree-view control.

Return value:
Returns the handle to the edit control if successful, or zero (0) otherwise.


Real API_Treeview_GetLineColor ( Real Control ID)

Returns the line color of the tree-view control.

Return value:
Returns the line color.
Real API_Treeview_GetRoot ( Real Control ID)

This function returns the handle to the root item of the tree-view control.

Return value:
Returns the item handle.
Real API_Treeview_GetSelected ( Real Control ID, Real Item Handle)

Checks wether a tree-view item is selected.

Return value:
Returns 1 when selected, 0 when not.
Real API_Treeview_GetParent ( Real Control ID, Real Item Handle)

This function returns the parent of a tree-view item.

Return value:
Returns the parent item handle.
Real API_Treeview_GetSelection ( Real Control ID)

This function returns the item handle of the selected tree-view item in a single selection tree-view.

Return value:
Returns the handle to the item if successful, or zero (0) otherwise.
Real API_Treeview_GetTextColor ( Real Control ID)

This function returns the text color of a tree-view control.

Return value:
Returns the text color.
Real API_Treeview_InsertItem ( Real Control ID, Real Parent Item Handle, Real Insert After Item Handle, Real Has Children)

This function inserts a new item into a tree-view control.

Return value:
Returns the item handle when created, or zero (0) otherwise.
Real API_Treeview_SetItemText ( Real Control ID, Real Item Handle, String Text)

This function changes the text of a tree-view item.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Treeview_SetItemState ( Real Control ID, Real Item Handle, Real State Flags)

This function sets the state flags of a tree-view item.

TVIS_BOLD
The item is bold.

TVIS_CUT
The item is selected as part of a cut-and-paste operation.

TVIS_EXPANDED
The item's list of child items is currently expanded; that is, the child items are visible. This value applies only to parent items.

TVIS_EXPANDEDONCE
The item's list of child items has been expanded at least once.

TVIS_EXPANDPARTIAL
A partially expanded tree-view item. In this state, some, but not all, of the child items are visible and the parent item's plus symbol is displayed.

TVIS_SELECTED
The item is selected. Its appearance depends on whether it has the focus. The item will be drawn using the system colors for selection.

TVIS_OVERLAYMASK
Mask for the bits used to specify the item's overlay image index.

TVIS_STATEIMAGEMASK
Mask for the bits used to specify the item's state image index.

TVIS_USERMASK
Same as TVIS_STATEIMAGEMASK.

Return value:
Returns true (1) when succesful, or false (0) otherwise.


Real API_Treeview_GetItemState ( Real Control ID, Real Item Handle)

This function returns the state flags of a tree-view item.

See API_Treeview_SetItemState for the state flags.

Return value:
Returns the item state flags.
Real API_Treeview_SetItemImages ( Real Control ID, Real Item Handle, Real Use Selected Image, Real Image, Real Selected Image)

This function sets the images of a tree-view item.

Set argument2 to 1 to change both the unselected and selected image, or set argument2 to 0 to set only the unselected image.

The images are image list numbers of the image list assigned to the tree-view.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Treeview_SelectItem ( Real Control ID, Real Item Handle)

This function selects a tree-view item.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Treeview_SetBkColor ( Real Control ID, Real Color)

This function sets the background color of a tree-view control.

Return value:
Returns the previous background color.
Real API_Treeview_SetCheckState ( Real Control ID, Real Item Handle, Real Is Checked)

This function changes the check state of a tree-view item.

Set argument2 to 1 to check it, set argument2 to 0 to uncheck it.

Return value:
The return value is not used.
Real API_Treeview_SetImageList ( Real Control ID, Real Kind Of Image, Real Image List Handle)

This function assigns a image list to the tree-view control.

Argument list:
Argument0: Control ID: The Control ID, returned by API_Treeview_Create.
Argument1: Kind of image:
0: Normal images.
1: State images.
Argument2: Image list handle: The image list handle, make one using API_ImageList_Create

Return value:
The return value is not used.
Real API_Treeview_SetLineColor ( Real Control ID, Real Color)

This function changes the line color of the tree-view control.

Return value:
Returns the previous color.
Real API_Treeview_SetTextColor ( Real Control ID, Real Color)

This function changes the text color of the tree-view control.

Return value:
Returns the previous color.
String API_Treeview_GetItemText ( Real Control ID, Real Color)

This function returns the text of a tree-view item.

Return value:
Returns the item text.
Real API_Treeview_EditLabel ( Real Control ID, Real Item Handle)

This function puts a listview item in the edit state.
This means the item changes into an edit box.

Return value:
Always returns 1.

Secondary check commands for tree-views:

TVN_SELCHANGED - The selection changed.
TVN_SELCHANGING - The selection is about to change.
NM_RCLICK - The item is right clicked
NM_CLICK - The item is left clicked
NM_DBLCLK - The item is double clicked
NM_RDBLCLK - The item is right double clicked

API_Check_TertiaryCommand returns the clicked item handle on a NM_ event.

Example:

Command = API_Check_Command (1); // Check commands for check handle 1

if ( Command == Treeview1 ) // Treeview1 sends a command
{
Second = API_Check_SecondaryCommand (1); // Check secondary command

if ( Second == TVN_SELCHANGED ) // The selection changed
{
Sel = API_Treeview_GetSelection (Treeview1) // Get new selection

Text = API_Treeview_GetItemText (Treeview1,Sel); // Get text of new selection

show_message ("The selection changed to "+Text+"."); // Inform user
}
}



Example code:

is
Treeview1 = API_Treeview_Create (Win,50,440,200,100,TVS_HASBUTTONS|TVS_LINESATROOT|TVS_HASLINES
,WS_EX_CLIENTEDGE);

Item1 = API_Treeview_InsertItem (Treeview1,TVI_ROOT,TVI_ROOT,1);
Item2 = API_Treeview_InsertItem (Treeview1,Item1,Item1,0);

API_Treeview_SetItemText (Treeview1,Item1,"Item 1");
API_Treeview_SetItemText (Treeview1,Item2,"Item 2");

API_Treeview_SetItemState (Treeview1,Item1,TVIS_BOLD);
API_Treeview_SetLineColor (Treeview1,c_red);
API_Treeview_SetTextColor (Treeview1,c_blue);

Return to help index