THitTest and THitTests are used in the GetHitTestInfoAt method.
THitTest = ( htAbove, htBelow, htNowhere, htOnItem, htOnButton, htOnIcon, htOnIndent, htOnLabel, htOnRight, htOnStateIcon, htToLeft, htToRight );
enum THitTest { htAbove, htBelow, htNowhere, htOnItem, htOnButton, htOnIcon, htOnIndent, htOnLabel, htOnRight, htOnStateIcon, htToLeft, htToRight };
THitTests is a set of THitTest values. THitTest can have any of the following values:
Value |
Means the point is |
htAbove |
Above the client area. |
htBelow |
Below the client area. |
htNowhere |
Inside the control, but not on an item. |
htOnItem |
On an item, its text, or its bitmap. |
htOnButton |
On a button. |
htOnIcon |
On an icon. |
htOnIndent |
On the indented area of an item. |
htOnLabel |
On a label. |
htOnRight |
On the right side of an item. |
htOnStateIcon |
On a state icon or bitmap associated with an item. |
htToLeft |
To the left of the client area. |
htToRight |
To the right of the client area. |
Delphi Examples:
{ The following code uses GetNodeAt to add a dragged node as a child of the node under the mouse when it is dropped. This example requires a populated TreeView. Also, the TTreeView DragMode property must be set to dmAutomatic, and the TTreeView OnDragOver event handler must be implemented to accept the drop. } procedure TForm1.TreeView1DragDrop(Sender, Source: TObject; X, Y: Integer); var AnItem: TTreeNode; AttachMode: TNodeAttachMode; HT: THitTests; begin if TreeView1.Selected = nil then Exit; HT := TreeView1.GetHitTestInfoAt(X, Y); AnItem := TreeView1.GetNodeAt(X, Y); if (HT - [htOnItem, htOnIcon, htNowhere, htOnIndent] <> HT) then begin if (htOnItem in HT) or (htOnIcon in HT) then AttachMode := naAddChild else if htNowhere in HT then AttachMode := naAdd else if htOnIndent in HT then AttachMode := naInsert; TreeView1.Selected.MoveTo(AnItem, AttachMode); end; end; procedure TForm1.TreeView1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := Source is TTreeView; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|