啊......哈哈,看了那个demo 也是自己画按钮和线的,就是这个函数
你把他加到textout前面调用就OK了,虽然样子难看了点.....-_-
procedure TCustomDrawForm.DrawButton(ARect: TRect; Node: TTreeNode);
var
cx, cy: Integer;
begin
cx := ARect.Left + TV.Indent div 2;
cy := ARect.Top + (ARect.Bottom - ARect.Top) div 2;
with TV.Canvas do
begin
Pen.Color := ButtonColorDialog.Color;
//draw horizontal line.
if Node.HasChildren then
begin
PenPos := Point(cx+FButtonSize, cy);
LineTo(ARect.Left + TV.Indent + FButtonSize, cy);
end else
begin
PenPos := Point(cx, cy);
LineTo(ARect.Left + TV.Indent + FButtonSize, cy);
end;
//draw half vertical line, top portion.
PenPos := Point(cx, cy);
LineTo(cx, ARect.Top-1);
if ((Node.GetNextVisible <> nil) and (Node.GetNextVisible.Level = Node.Level))
or (Node.GetNextSibling <> nil) then
//draw bottom portion of half vertical line.
begin
PenPos := Point(cx, cy);
LineTo(cx, ARect.Bottom+1);
end;
if Node.HasChildren then
begin
//Let's try a circular button instead
Ellipse(cx-FButtonSize, cy-FButtonSize, cx+FButtonSize, cy+FButtonSize);
//draw the horizontal indicator.
PenPos := Point(cx-FButtonSize+2, cy);
LineTo(cx+FButtonSize-2, cy);
//draw the vertical indicator if the node is collapsed
if not Node.Expanded then
begin
PenPos := Point(cx, cy-FButtonSize+2);
LineTo(cx, cy+FButtonSize-2);
end;
end;
//now connect vertical lines of higher level nodes.
Node := Node.Parent;
while Node <> nil do
begin
cx := cx - TV.Indent;
if Node.GetNextSibling <> nil then
begin
PenPos := Point(cx, ARect.Top);
LineTo(cx, ARect.Bottom);
end;
Node := Node.Parent;
end;
end;
end;