Hint & TTreeView

Hi all;

I want my application show the hint of an item on the tree view as
soon as the mouse moves over that item, but it does not unless i click on that item.

(NOTE: i change the hint of the tree view in the on mouse move event, is there an additional call that i should do?)

Comments

  • : Hi all;
    :
    : I want my application show the hint of an item on the tree view as
    : soon as the mouse moves over that item, but it does not unless i click on that item.
    :
    : (NOTE: i change the hint of the tree view in the on mouse move event, is there an additional call that i should do?)
    :
    Here is a code, which shows the hints as the mouse moves over the tree. It is not perfect, but it works without needing to click the nodes.
    [code]
    procedure TForm1.TreeView1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
    begin
    if TreeView1.GetNodeAt(X,Y)<>nil then
    begin
    TreeView1.Hint := TreeView1.GetNodeAt(X,Y).Text;
    Application.ActivateHint(Mouse.CursorPos);
    end;
    end;
    [/code]
  • Thank you, but I have one more question about the tree view component's
    GetNodeAt method, if you don't mind.

    When i move the mouse to a blank place just on the same line with a node, it returns that node. Shouldn't it return nil? Or how can i make it return nil if the position of the mouse is not on a node's text space, even if this point horizontally lies on the same line with a node?

    Thanx.

    : : Hi all;
    : :
    : : I want my application show the hint of an item on the tree view as
    : : soon as the mouse moves over that item, but it does not unless i click on that item.
    : :
    : : (NOTE: i change the hint of the tree view in the on mouse move event, is there an additional call that i should do?)
    : :
    : Here is a code, which shows the hints as the mouse moves over the tree. It is not perfect, but it works without needing to click the nodes.
    : [code]
    : procedure TForm1.TreeView1MouseMove(Sender: TObject; Shift: TShiftState; X,
    : Y: Integer);
    : begin
    : if TreeView1.GetNodeAt(X,Y)<>nil then
    : begin
    : TreeView1.Hint := TreeView1.GetNodeAt(X,Y).Text;
    : Application.ActivateHint(Mouse.CursorPos);
    : end;
    : end;
    : [/code]
    :

  • : Thank you, but I have one more question about the tree view component's
    : GetNodeAt method, if you don't mind.
    :
    : When i move the mouse to a blank place just on the same line with a node, it returns that node. Shouldn't it return nil? Or how can i make it return nil if the position of the mouse is not on a node's text space, even if this point horizontally lies on the same line with a node?
    :
    : Thanx.
    :
    : : : Hi all;
    : : :
    : : : I want my application show the hint of an item on the tree view as
    : : : soon as the mouse moves over that item, but it does not unless i click on that item.
    : : :
    : : : (NOTE: i change the hint of the tree view in the on mouse move event, is there an additional call that i should do?)
    : : :
    : : Here is a code, which shows the hints as the mouse moves over the tree. It is not perfect, but it works without needing to click the nodes.
    : : [code]
    : : procedure TForm1.TreeView1MouseMove(Sender: TObject; Shift: TShiftState; X,
    : : Y: Integer);
    : : begin
    : : if TreeView1.GetNodeAt(X,Y)<>nil then
    : : begin
    : : TreeView1.Hint := TreeView1.GetNodeAt(X,Y).Text;
    : : Application.ActivateHint(Mouse.CursorPos);
    : : end;
    : : end;
    : : [/code]
    : :
    :
    :
    You have to manually check if the position of the mous is within the DisplayRect() of the node. You can use the PtInRect() (windows unit) for that.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories