Back to Devexpress

How to Determine a Visual Element Under the Mouse Pointer

vcl-152031-expresslayoutcontrol-how-to-determine-a-visual-element-under-the-mouse-pointer.md

latest2.8 KB
Original Source

How to Determine a Visual Element Under the Mouse Pointer

  • Dec 28, 2020

The following example demonstrates how to provide hints for the Customization Form‘s Available Items and Layout Tree View panes using the layout control’s GetHitTest method, the TTimer.OnTimer event, and the TcxHintStyleController component.

delphi
uses
// ...
  Controls, cxControls, cxHint;
// ...
procedure <Form>.<Timer>Timer(Sender: TObject);
var
  AHitTest: TdxCustomLayoutHitTest;
  AHintPoint: TPoint;
begin
  AHitTest := <dxLayoutControl>.GetHitTest(<dxLayoutControl>.ScreenToClient(GetMouseCursorPos));
  case (AHitTest.HitTestCode) of
    htAvailableItems:
    begin
      AHintPoint := GetMouseCursorPos;
      <cxHintStyleController>.ShowHint(AHintPoint.X, AHintPoint.Y + 25, 'Available Items pane:', 'Create new layout elements, or change the visibility of existing elements');
    end;
    htTreeViewItems:
    begin
      AHintPoint := GetMouseCursorPos;
      <cxHintStyleController>.ShowHint(AHintPoint.X, AHintPoint.Y + 25, 'Layout Tree View pane:', 'Rearrange layout elements');
    end;
    else
      <cxHintStyleController>.HideHint;
  end;

The following image shows the result of executing the code:

See Also

TdxCustomLayoutHitTest

TdxCustomLayoutItemHitTest

TdxLayoutBasicItemHitTest

TdxLayoutClientAreaHitTest

TdxLayoutCustomizeFormAvailableItemsHitTest

TdxLayoutCustomizeFormHitTest

TdxLayoutCustomizeFormTreeViewItemsHitTest

TdxLayoutGroupHitTest

TdxLayoutItemHitTest

TdxLayoutNoneHitTest

TdxLayoutSizeHitTest

TdxLayoutSplitterHitTest

TdxLayoutTabbedGroupHitTest

TdxCustomLayoutControl.GetHitTest

TdxLayoutContainer.GetHitTest