Y
YuZi
Unregistered / Unconfirmed
GUEST, unregistred user!
在TreeView自绘过程中(CustomDrawItem),我设置DefaultDraw:=False; 实现自己完全自绘节点的Button、图标、文本,但用Canvas.Textout时却发现始终无法设置文字的字体(即Font属性设置被忽略了),只有当DefaultDraw:=True时才可以按Font属性自定义字体,但这样我又不能完全自绘节点的button 、图标了,真是两难,我曾尝试直接用API输出procedure TForm1.TVCustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);var NodeRect: TRect;begin DefaultDraw := False; with TreeView1 do begin NodeRect := Node.DisplayRect(False); NodeRect.Top := NodeRect.Top + (TreeView_GetItemHeight(Self.Handle) - Canvas.TextHeight('A')) div 2; Canvas.Font.Color := clRed; Canvas.TextOut(NodeRect.Left, NodeRect.Top, Node.Text); end;end;