- C++ 60%
- Pascal 23.8%
- C 8%
- CMake 5.7%
- PowerShell 2.2%
- Other 0.3%
| cmake | ||
| docs | ||
| examples | ||
| include/treelistview | ||
| pascal | ||
| scripts | ||
| src | ||
| tests | ||
| thirdparty | ||
| .clang-format | ||
| .clang-tidy | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .gitmodules | ||
| AGENTS.md | ||
| CMakeLists.txt | ||
| CMakePresets.json | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| README.md | ||
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.
- 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_NOTIFYevents, 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.
