Search code examples
delphivirtualtreeviewtvirtualstringtree

TVirtualStringTree change cursor when hoverering an image


How can I change the cursor when I'm hovering an ImageIndex from a node

Basically I have an attach icon displayed on a node and i would like to let user understand, by changing the cursor, that he have the possibility to download the file by pressing on it.


Solution

  • In the tree's OnMouseMove event check wether the cursor is over the "icon area" and change the cursor accordingly. Something like

    procedure TForm1.VTMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
    var HitInfo: THitInfo;
    begin
      VT.GetHitTestInfoAt(X, Y, True, HitInfo);
      if(hiOnNormalIcon in HitInfo.HitPositions)then begin
         VT.Cursor := crHandPoint;
      end else begin
         VT.Cursor := crDefault;
      end;
    end;
    

    The VT variable is your TVirtualStringTree object.