type
TThickness = -1 .. +1;
const
cGBGridList: array [TThickness, TThickness, TThickness, TThickness] of WideString =
(((('┼', '├', '┽'), ('┴', '└', '┵'), ('╁', '┟', '╅')), (('┤', '│', '┥'), ('┘', '↑', '┙'), ('┧', '︾', '┪')),
(('┾', '┝', '┿'), ('┶', '┕', '┷'), ('╆', '┢', '╈'))), ((('┬', '┌', '┭'), ('─', '→', '《'), ('┰', '┎', '┱')),
(('┐', '↓', '┑'), ('←', ' ', '<'), ('┒', '∨', '┓')), (('┮', '┍', '┯'), ('》', '>', '━'), ('┲', '┏', '┳'))),
((('╀', '┞', '╃'), ('┸', '┖', '┹'), ('╂', '┠', '╉')), (('┦', '︽', '┩'), ('┚', '∧', '┛'), ('┨', '┃', '┫')),
(('╄', '┡', '╇'), ('┺', '┗', '┻'), ('╊', '┣', '╋'))));
function TreeViewToDisplay(mTreeView: TTreeView; mStrings: TStrings; mHBold: Boolean = True;
mVBold: Boolean = True): Boolean;
var
I, J: Integer;
T, S: string;
H, V: Integer;
vTreeNode: TTreeNode;
begin
Result := False;
if not Assigned(mTreeView) then
Exit;
if not Assigned(mStrings) then
Exit;
mStrings.Clear;
H := Iif(mHBold, +1, -1);
V := Iif(mVBold, +1, -1);
J := 0;
with mTreeView do
try
for I := 0 to Pred(Items.Count) do
begin
if J > Items[I].Level then
T := Copy(T, 1, Length(T) - (J - Items[I].Level) * 2)
else if J < Items[I].Level then
T := T + S;
vTreeNode := Items[I].GetNextSibling;
if not Assigned(vTreeNode) then
begin
mStrings.Add(T + cGBGridList[V, H, 00, 00] + Items[I].Text);
S := cGBGridList[00, 00, 00, 00];
end
else
begin
mStrings.Add(T + cGBGridList[V, H, V, 00] + Items[I].Text);
S := cGBGridList[V, 00, V, 00];
end;
J := Items[I].Level;
end;
except
Exit;
end;
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TreeViewToDisplay(TreeView1, Memo1.Lines, CheckBox1.Checked, CheckBox2.Checked);
end;