Search code examples
delphidelphi-xe2hint

Application.ActivateHint shows hint on incorrect position on Delphi XE2


I am using Application.ActivateHint(p), where p: TPoint, to show hint on specified position. But it always shows on actual mouse coordinates on Delphi XE2.

Please look to the stack:

Main.ApplicationEventsShowHint('Hint String Here...',True,$18FB14)
:5049c644 TCustomApplicationEvents.DoShowHint + $20
:5049d043 TMultiCaster.DoShowHint + $4B
:50454a6b TApplication.ActivateHint + $213
RxDBCtrl.TRxDBGrid.MouseMove([],934,45)

On RxDBCtrl.TRxDBGrid.MouseMove I call TApplication.ActivateHint with correct screen coordinates as the parameter. But on Main.ApplicationEventsShowHint(var HintStr: string; var CanShow: Boolean; var HintInfo: THintInfo) the value of HintInfo.HintPos is the same as actual mouse coordinates. The value passed as the parameter to TApplication.ActivateHint is lost.

Why this happens? How to show a hint on desired coordinates on Delphi XE2?

Thanks a lot for the help!


Solution

  • Problems were from the following method:

    procedure TJvDBGrid.CMHintShow(var Msg: TCMHintShow); message CM_HINTSHOW;
    

    And the new property of the component:

    type
      TJvDBGridCellHintPosition = (gchpDefault, gchpMouse);
    
    property CellHintPosition: TJvDBGridCellHintPosition; default gchpDefault;
    

    To fix the issue I use the following code before call a hint:

    ShowCellHint := True;
    CellHintPosition := gchpDefault;
    

    The second line is optional. But I saw very strange gchpMouse value of the CellHintPosition property on the debugger.