Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VCL based on TTreeView 1

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
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
 
Need to declare (in protected section):
---------------------------------------
function IsCustomDrawn(Target: TCustomDrawTarget; Stage: TCustomDrawStage): Boolean; override;
---------------------------------------

and in the implementation:
---------------------------------------
function TMyTree.IsCustomDrawn(Target: TCustomDrawTarget; Stage: TCustomDrawStage): Boolean;
begin
Result := True;
end;
---------------------------------------

Thanks to Gerrit Beuze
(borland.public.delphi.vcl.components.using.win32)

Hope this will help somebody else...

RC

 
star for your solution!

looked at it myself, didn't realize it was that simple.

[thumbsup]

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top