You're asking about the difference between two tree control implementations in the FiveWin framework: one using TLinkList (a custom implementation) and TTreeView (which wraps the Windows API TreeView control), and whether image lists can be used with both.<cite />
Key Differences
TTreeView (Windows API Control)
TTreeView is a wrapper around the native Windows TreeView control (SysTreeView32) 0-cite-0 . It inherits from TControl and provides direct access to Windows API functionality 0-cite-1 . This implementation:
- Uses the Windows Common Controls TreeView (SysTreeView32)
- Stores items in aItems array of TTreeItem objects 0-cite-2
- Supports native Windows features like checkboxes (TVS_CHECKBOXES), editable labels (TVS_EDITLABELS), and standard tree styles 0-cite-3
- Has built-in Windows API support for image lists via SetImageList() method 0-cite-4
TTreeView with TLinkList (Custom Implementation)
The custom tree implementation in samples/trees/treeview.prg uses TLinkList as its underlying data structure 0-cite-5 . This implementation:
- Uses a custom listbox-based control with owner-draw functionality (LBS_OWNERDRAWVARIABLE) 0-cite-6
- Stores tree structure in RootLink (a TTreeLink object) 0-cite-7
- Manually handles drawing and tree navigation
- Uses bitmap arrays (aBitmaps, aMasks) for icons 0-cite-7
- Creates control as "LISTBOX" class 0-cite-8
Image List Support
Yes, image lists work with both implementations, but differently:
TTreeView (Windows API) - Native ImageList Support
The Windows API TTreeView has native support for TImageList through the SetImageList() method 0-cite-4 , which calls the Windows API function TreeView_SetImageList 0-cite-9 .
Example usage: 0-cite-10
TLinkList-based TTreeView - Bitmap Arrays
The custom implementation uses bitmap arrays instead of image lists. You pass bitmaps via the acBitmaps and acMasks parameters 0-cite-11 , which are stored in aBitmaps and aMasks data members 0-cite-7 . The SetBitmaps() method handles this 0-cite-12 .
Example usage: 0-cite-13
Notes
The Windows API TTreeView (in source/classes/ttreevie.prg) is the modern, recommended approach as it leverages native Windows controls with full OS support for accessibility, theming, and performance 0-cite-14 . The custom TLinkList-based implementation (in samples/trees/treeview.prg) appears to be an older approach from before Windows Common Controls were widely available, maintained for backward compatibility<cite />.
Wiki pages you might want to explore:
Citations
File: source/classes/ttreevie.prg (L42-48)
#define TVS_HASBUTTONS 1
#define TVS_HASLINES 2
#define TVS_LINESATROOT 4
#define TVS_SHOWSELALWAYS 32 // 0x0020
#define TVS_DISABLEDRAGDROP 16 // 0x0010
#define TVS_CHECKBOXES 256 // 0x0100
#define TVS_EDITLABELS 8
File: source/classes/ttreevie.prg (L50-61)
#define CTRL_NAME "SysTreeView32"
//----------------------------------------------------------------------------//
CLASS TTreeView FROM TControl
DATA aItems
DATA oImageList
DATA bChanged
DATA bExpanded
DATA hEdit
File: source/classes/ttreevie.prg (L125-125)
METHOD SetImageList( oImageList )
File: samples/trees/treeview.prg (L43-53)
CLASS TTreeView FROM TControl
CLASSDATA lRegistered AS LOGICAL
DATA RootLink, nIndent, aBitmaps, aMasks, oItem
DATA oEditTimer, lEdit, oTipTimer
DATA nTreeStyle
METHOD New( nRow, nCol, nWidth, nHeight, oWnd, acBitmaps, acMasks, ;
bChange, bDblClick, bValid, nHelpID, ;
nClrFore, nClrBack, oFont, cMsg, bWhen, lPixel, nTreeStyle ) CONSTRUCTOR
File: samples/trees/treeview.prg (L62-62)
METHOD cToChar() INLINE Super:cToChar( "LISTBOX" )
File: samples/trees/treeview.prg (L126-126)
METHOD SetBitmaps( acBitmaps )
File: samples/trees/treeview.prg (L183-186)
::nStyle = nOr( WS_CHILD, WS_VISIBLE, WS_BORDER, WS_TABSTOP, ;
WS_VSCROLL, WS_HSCROLL, ;
LBS_NOTIFY, LBS_OWNERDRAWVARIABLE, ;
LBS_NOINTEGRALHEIGHT, LBS_NOREDRAW )
File: source/winapi/treeview.c (L100-109)
HB_FUNC( TVSETIMAGELIST ) // ( hWnd, hImageList, nType )
{
#ifndef _WIN64
hb_retnl( ( LONG ) TreeView_SetImageList( ( HWND ) hb_parnl( 1 ),
( HIMAGELIST ) hb_parnl( 2 ), hb_parnl( 3 ) ) );
#else
hb_retnll( ( LONGLONG ) TreeView_SetImageList( ( HWND ) hb_parnll( 1 ),
( HIMAGELIST ) hb_parnll( 2 ), hb_parnl( 3 ) ) );
#endif
}
File: samples/test/testtree.prg (L32-44)
oImageList = TImageList():New()
oBmp1 = TBitmap():Define( "folder",, oWnd )
oBmp2 = TBitmap():Define( "fldMask",, oWnd )
oImageList:Add( oBmp1, oBmp2 )
oTree = TTreeView():New( 2, 0, oWnd )
oTree:bChanged = { || oWnd:SetText( If( oTree:GetSelected():GetParent() != nil,;
oTree:GetSelected():GetParent():cPrompt + " + ", "" ) + ;
oTree:GetSelText() ) }
oTree:SetImageList( oImageList )
File: samples/test/testtre3.prg (L52-63)
oImageList := TImageList():New() // imagelist items are zero-based!
oImageList:Add( TBitmap():Define( "folder",, oChild ), ; // nImage == 0 (default if not specified)
TBitmap():Define( "fldMask",, oChild ) )
oImageList:Add( TBitmap():Define( "form",, oChild ), ; // nImage == 1
TBitmap():Define( "frmMask",, oChild ) )
oImageList:Add( TBitmap():Define( "icon",, oChild ),; // nImage == 2
TBitmap():Define( "icoMask",, oChild ) )
oImageList:Add( TBitmap():Define( "bitmap",, oChild ),; // nImage == 4
TBitmap():Define( "bmpMask",, oChild ) )
oTree := TTreeView():New( 2, 0, oChild )
File: docs/reference/classes/TTreeView.md (L1-11)
# TTreeView Class
The `TTreeView` class provides a comprehensive implementation of a tree view control that displays hierarchical data in a collapsible tree structure. It supports advanced features including checkboxes, editable labels, custom images, and extensive event handling.
**Source File:** [source/classes/ttreevie.prg](../../../source/classes/ttreevie.prg)
## Overview
The `TTreeView` class encapsulates the Windows TreeView control, providing a high-level interface for managing hierarchical data structures. As a subclass of `TControl`, it inherits all standard control functionality while adding specialized behavior for tree navigation, item management, and user interaction.
Tree views are essential UI components for displaying hierarchical data such as file systems, organizational charts, navigation menus, and structured data with parent-child relationships.