Mirror

How to control the hint position (Views: 101)


Problem/Question/Abstract:

How do I force hints to be shown where I want? The hint for a stringgrid currently is showing up right below it, where it doesn't get noticed if the user is moving his/ her mouse over the top of the grid and the grid is large. Ideally I'd want that little yellow boxed hint to show as close to the cursor as possible.

Answer:

procedure TArrangerForm.AppShowHint(var HintStr: string; var CanShow: Boolean;
  var HintInfo: THintInfo);
var
  i: integer;
begin
  with HintInfo do
  begin
    if (HintControl = LocatorPanel1) then
      with LocatorPanel1 do
      begin
        if not (csLButtonDown in ControlState) then
        begin
          i := FindListMarker(CursorPos.X);
          if (i >= 0) then
          begin
            HintPos := ClientToScreen(Point(TimeToPixel(MarkerList.Markers[i].Offset) + 10, 2));
            Application.HintPause := 0;
            Application.HintHidePause := MaxInt;
            CanShow := True;
            exit;
          end;
        end;
        CanShow := False;
      end;
  end;
  Application.HintPause := 800;
  Application.HintHidePause := 2500;
end;

<< Back to main page