Page 1 of 1

Showing TeeTree hints

Posted: Fri Mar 24, 2006 7:02 pm
by 9235788
I have a need to show the hint message when the mouse is over a TTreeNodeShape and the entire shape is in view. This is due to Zooming to the point that description is unreadable. I have been unable to figure out how to get around the CancelHint call during the mouse move. By the way for future versions I would concider a property that would turn off the bounds checking for the showhint.

Posted: Mon Mar 27, 2006 5:31 pm
by Tom
Hi,

You could use the following code:

Code: Select all

procedure TForm2.Tree1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
  var  MyNode : TTreeNodeShape;
begin
    MyNode := Tree1.ClickedShape(X,Y);
    If MyNode<>Nil then begin
      if MyNode.Text.Count  > 0 then
        Tree1.Hint := MyNode.Text[0];
    end;
  end;
end;
Regards,
tom

Posted: Thu Apr 06, 2006 10:27 pm
by 9235788
Thanks Tom.

That was what I was doing and it doesn't work. By the time TeeTree calls my mousemove event handler it has already determined that the object is completely displayed on the screen and called the CancelHint system routine. I set the hint text but the hint doesn't show. At least I am assuming the CancelHint call is the reason. There might be something else.

Posted: Wed Apr 12, 2006 6:04 pm
by Tom
Hi,

Be sure ShowHintShapes is set to False

This is okay, since you handle the hint yourself, so if the shape is only partly visible it's hint is handled by your code too

Posted: Fri Apr 21, 2006 2:35 pm
by 9235788
Thanks Tom. That was the last hint I needed to get it to work. I had to add a little more to make it work. So for others looking to do the hint control in their own application let me give my final solution.

In the form's OnCreate I entered the statement:
ttree1.ShowHintShapes := False;

I then have the following OnMouseMove code.

Code:
procedure TForm1.ttree1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var MyNode : TTreeNodeShape;
begin
MyNode := ttree1.ClickedShape(X,Y);
If Assigned(node) then begin
if MyNode.Text.Count > 0 then
begin
Application.HintShortPause := 0;
Application.HintPause := 0;
ttree1.Hint := MyNode.Text[0];
ttree1.ShowHint := True;
end
else
begin
ttree1.Hint := '';
Application.CancelHint;
end;
end;
end;
end;

Thanks for your insight and help.