Hit Test TTreview plus/minus (collapse/expand) icon

I am using a TTreeview component in Delphi and I have customized the drag and drop functions. I start the drag on the mouse down (since it is a custom behavior), but I don't want to start the drag event when the user click on the +/- or expand and collapse icons.

Is there a way to know if the user has clicked on the caption of the node or on the expand/collapse icon?

Thanks!


The TTreeView component includes the GetHitTestInfoAt method for this purpose.

procedure TForm1.TreeView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  HitTests: THitTests;
begin
  HitTests := TreeView1.GetHitTestInfoAt(X, Y);
  if htOnButton in HitTests then
    //do something
  else if htOnLabel in HitTests then
    //do something else
  else if ......

The full list of possible members of the THitTests set is:

  • htAbove
  • htBelow
  • htNowhere
  • htOnItem
  • htOnButton
  • htOnIcon
  • htOnIndent
  • htOnLabel
  • htOnRight
  • htOnStateIcon
  • htToLeft
  • htToRight
  • 链接地址: http://www.djcxy.com/p/35084.html

    上一篇: 如何防止拖动某个虚拟StringTree NodeLevel?

    下一篇: 点击测试TTreview加/减(折叠/展开)图标