Problem with TTreeNodeShape.ClickedImage

TeeTree VCL for Borland Delphi and C++ Builder.
Post Reply
Nico
Newbie
Newbie
Posts: 8
Joined: Thu Jul 21, 2005 4:00 am
Location: France

Problem with TTreeNodeShape.ClickedImage

Post by Nico » Tue Jul 26, 2005 8:40 am

Hi

I have node with a picture (ImageIndex = tiChecked) and I'd like to know when the user click on this picture. So I wrote :

OnNodeClick(Sender: TTreeNodeShape;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Sender.ClickedImage(X, Y) then
begin
...
end;

...
end;

It works fine as long as I don't have any scrollbars with position <> 0 in the TeeTree component.
When I have a scrollbar with position <> 0, the XY coordinates are relative to component space and not the tree space.

Could you tell me what I have done wrong ?

Thanks

Nico

tom
Advanced
Posts: 211
Joined: Mon Dec 01, 2003 5:00 am
Contact:

Post by tom » Tue Jul 26, 2005 5:32 pm

Hi Nico,

You've nothing done wrong. I think it is a bug in the code.
You could solve it in two ways:

Change the code you present below to:

Code: Select all

OnNodeClick(Sender: TTreeNodeShape; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   Sender.Tree.Canvas.Calculate2DPosition(X,Y,0);
   if Sender.ClickedImage(X, Y) then
   begin
   ...
   end;
   ...
end; 
or change the clickedImage method in teeTree.pas as follows:

Code: Select all

Function TTreeNodeShape.ClickedImage(x,y:Integer):Boolean;
begin
  Tree.Canvas.Calculate2DPosition(X,Y,0);
  result:=(IImageWidth>0) and PointInRect(ImageRect,x,y);
end;
Regards,
tom at steema.com

Nico
Newbie
Newbie
Posts: 8
Joined: Thu Jul 21, 2005 4:00 am
Location: France

Post by Nico » Wed Jul 27, 2005 6:59 am

It works fine now

Thanks a lot Tom

Nico

Post Reply