¿Cómo dibujar el rectángulo de selección con estilo de TTreeView durante AdvancedCustomDrawItem?
Estoy haciendo costumbreTTreeView
dibujar desde cero usandoOnAdvancedCustomDrawItem
evento, y me pregunto cómo representar correctamente estos rectángulos de selección y selección en el fondo de mis elementos dibujados por el propietario? Tienen el estilo de Vista / 7, por lo que no puedo simplemente rellenar el fondo con un color sólido.
Traté de dibujar mis artículos encdPostPaint
etapa, pero si me voyDefaultDraw := True
acdPrePaint
Para dibujar el fondo de selección, se produce el dibujo predeterminado completo, incluido el texto de los elementos.
procedure TForm1.TreeView1AdvancedCustomDrawItem(Sender: TCustomTreeView;
Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage; var PaintImages,
DefaultDraw: Boolean);
begin
case Stage of
cdPreErase:
begin
DefaultDraw := True;
end;
cdPostErase:
begin
DefaultDraw := True;
end;
cdPrePaint:
begin
// I thought this will paint only the selected/hot backgrounds,
// however this will paint whole item, including text.
DefaultDraw := True;
end;
cdPostPaint:
begin
DefaultDraw := False;
// painting my owner-draw text
// .........
end;
end;
PaintImages := False;
end;