A Win32 tree-list control: hierarchy column plus resizable, sortable columns. C ABI for C, C++ and Lazarus/Free Pascal.
  • C++ 60%
  • Pascal 23.8%
  • C 8%
  • CMake 5.7%
  • PowerShell 2.2%
  • Other 0.3%
Find a file
2026-10-30 02:10:27 -06:00
cmake feat(control): add the TreeListView window and DLL exports 2026-10-29 21:47:31 -06:00
docs docs: add a demo screenshot to the README 2026-10-30 02:10:27 -06:00
examples feat(example): add options demos for C++ and Lazarus 2026-10-29 22:27:49 -06:00
include/treelistview feat(control): add the TreeListView window and DLL exports 2026-10-29 21:47:31 -06:00
pascal feat(pascal): add the Free Pascal binding and LCL component 2026-10-29 22:12:47 -06:00
scripts feat(example): add a Lazarus demo with a self-test 2026-10-29 22:12:47 -06:00
src fix(control): answer header custom draw from a private host window 2026-10-29 22:17:28 -06:00
tests test(pascal): check record layouts and drive the DLL from Free Pascal 2026-10-29 22:12:47 -06:00
thirdparty feat(core): add node tree, sorting, view state and check cascade 2026-10-29 21:31:55 -06:00
.clang-format build: add clang-format, clang-tidy and format/tidy targets 2026-10-29 21:28:53 -06:00
.clang-tidy build: skip the C header and rc files in clang-tidy 2026-10-29 21:47:31 -06:00
.editorconfig chore: add editorconfig, gitattributes and gitignore 2026-10-29 21:28:53 -06:00
.gitattributes chore: add editorconfig, gitattributes and gitignore 2026-10-29 21:28:53 -06:00
.gitignore feat(example): add options demos for C++ and Lazarus 2026-10-29 22:27:49 -06:00
.gitmodules chore: add editorconfig, gitattributes and gitignore 2026-10-29 21:28:53 -06:00
AGENTS.md docs: add README, CONTRIBUTING and AGENTS 2026-10-29 22:13:22 -06:00
CMakeLists.txt feat(example): add a lazy-loading file browser 2026-10-29 21:47:31 -06:00
CMakePresets.json build: add cmake project, msys2 toolchains, presets and scripts 2026-10-29 21:28:54 -06:00
CONTRIBUTING.md docs: add README, CONTRIBUTING and AGENTS 2026-10-29 22:13:22 -06:00
LICENSE chore: add zlib license 2026-10-29 21:28:53 -06:00
README.md docs: add a demo screenshot to the README 2026-10-30 02:10:27 -06:00

TreeListView

A Win32 tree-list control: a hierarchy column plus resizable, sortable columns under a native header. It is an ordinary window class with a C interface, so C, C++ and Lazarus/Free Pascal programs (32- and 64-bit) can all use the same treelistview.dll.

The Win32 file browser demo in dark mode

  • Tree column with expand/collapse, lines, icons, tri-state check boxes, lazy children
  • Resizable columns, optional per-column sorting (text or numeric key), multi-select, type-ahead
  • DPI-aware metrics, Explorer visual styles, dark mode (follows Windows or forced), tooltips
  • Custom draw notifications, WM_NOTIFY events, no C++ exceptions across the boundary
  • Targets Windows 10+. Newer APIs are loaded dynamically to keep Windows 7 possible, but that is untested.

Build

Requires MSYS2 (found at D:\msys64, C:\msys64 or %MSYS2_ROOT%) with the UCRT64 (x64) and MINGW32 (x86) toolchains, CMake and Ninja. The DLL links the GCC runtime statically and imports only Windows system DLLs.

.\scripts\build.ps1                 # x64 debug build + tests
.\scripts\build.ps1 -Arch all       # x64 and x86
.\scripts\build.ps1 -Arch x86 -Lazarus   # also the Lazarus package, demo and its self-test

Output goes to build/<preset>/bin/treelistview.dll, with the import library in build/<preset>/lib. Include include/treelistview/treelistview.h from the source tree, or cmake --install the build.

Use from C or C++

#include <treelistview/treelistview.h>

TreeList_Register();
HWND tree = CreateWindowExW(0, TLV_CLASSNAMEW, L"", WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
    TLVS_HASBUTTONS | TLVS_FULLROWSELECT, 0, 0, 400, 300, parent, nullptr, instance, nullptr);

TLVCOLUMNW column{};
column.mask = TLVCF_TEXT | TLVCF_WIDTH;
column.pszText = const_cast<LPWSTR>(L"Name");
column.cx = 240;
TreeList_InsertColumn(tree, -1, &column);

TLVINSERTSTRUCTW insert{};
insert.hParent = TLVI_ROOT;
insert.hInsertAfter = TLVI_LAST;
insert.item.mask = TLVIF_TEXT;
insert.item.pszText = const_cast<LPWSTR>(L"First");
HTLVNODE node = TreeList_InsertNode(tree, &insert);

The control is driven by TLVM_* messages and reports through WM_NOTIFY (TLVN_*, NM_CLICK, ...). include/treelistview/treelistview.h is the reference; examples/win32 is a file browser and examples/win32-options toggles every option.

Use from Lazarus / Free Pascal

Add pascal/treelistview_lcl.lpk (or the pascal folder to your unit path) and put treelistview.dll next to the executable. The DLL and the program must have the same bitness.

uses TreeListViewApi, TreeListViewCtrl;

Tree := TTreeListView.Create(Self);
Tree.Parent := Self;
Tree.Align := alClient;
Tree.Columns.Add.Caption := 'Name';
Tree.AddNode(TLVI_ROOT, 'First');

TreeListViewApi is the raw binding; TreeListViewCtrl is the LCL component (Windows widgetset only). See examples/lazarus (file browser) and examples/lazarus/options (toggles every option). The nodes live in the native control, so they are lost if LCL recreates the window handle.

License

zlib, see LICENSE.