Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to Determine a Visual Element Under the Mouse Pointer

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