Hi,
I've built a VCL based on TTreeView control. Some code have placed within the [protected function CustomDrawItem override] of the VCL.
The code is to modify default font to show properties per node [bold for selected item, gray for locked items].
Also, there's a call to DrawFocusRect over the selected item.
--------------------------------------------------------
function TMyTree.CustomDrawItem(Node: TTreeNode; State:
TCustomDrawState; Stage: TCustomDrawStage; var
PaintImages: Boolean): Boolean;
begin
inherited CustomDrawItem(Node, State, Stage, PaintImages);
if Stage = 1 then
begin
PaintImages := True;
// changing font properties & call DrawFocusRect...
end;
Result := True;
end;
--------------------------------------------------------
The problem I have is that for this feature to work properly, I need to declare a fake CustomDrawItem for each implementation of the VCL (that is, only inserting inherited within the event makes it working fine).
--------------------------------------------------------
procedure TForm1.MyTreeCustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode;
State: TCustomDrawState; var DefaultDraw: Boolean);
begin
inherited;
end;
--------------------------------------------------------
What do I missing? How to avoid the inherited call in each implementation of my MyTree?
Thanks in advance for help.
RC
I've built a VCL based on TTreeView control. Some code have placed within the [protected function CustomDrawItem override] of the VCL.
The code is to modify default font to show properties per node [bold for selected item, gray for locked items].
Also, there's a call to DrawFocusRect over the selected item.
--------------------------------------------------------
function TMyTree.CustomDrawItem(Node: TTreeNode; State:
TCustomDrawState; Stage: TCustomDrawStage; var
PaintImages: Boolean): Boolean;
begin
inherited CustomDrawItem(Node, State, Stage, PaintImages);
if Stage = 1 then
begin
PaintImages := True;
// changing font properties & call DrawFocusRect...
end;
Result := True;
end;
--------------------------------------------------------
The problem I have is that for this feature to work properly, I need to declare a fake CustomDrawItem for each implementation of the VCL (that is, only inserting inherited within the event makes it working fine).
--------------------------------------------------------
procedure TForm1.MyTreeCustomDrawItem(Sender: TCustomTreeView; Node: TTreeNode;
State: TCustomDrawState; var DefaultDraw: Boolean);
begin
inherited;
end;
--------------------------------------------------------
What do I missing? How to avoid the inherited call in each implementation of my MyTree?
Thanks in advance for help.
RC