5

I'm trying to use Application.ActivateHint in a button to show it's hint.
It's simply not working, no hint is shown in target button.
There's no container beyond the form.

procedure TForm1.btn2Click(Sender: TObject);
var 
  PosScr1: TPoint;
  Btn_Test: TButton;

begin
  Btn_Test := nil;

  Btn_Test := TButton(Self.FindComponent('Btn_Test'));
  if not Assigned(Btn_Test) then
  begin
    // Generated by GExperts "Component to Code"
    // To clone the original target button 
    // and leave the method self-suficient for
    // StackOverflow
    Btn_Test := TButton.Create(Self);
    with Btn_Test do
    begin
      Name := 'Btn_Test';
      Parent := Self;
      Left := 176;
      Top := 56;
      Width := 75;
      Height := 25;
      Hint := 'Testing';
      Caption := 'Btn_Test';
      ParentShowHint := False;
      ShowHint := True;
      TabOrder := 0;
    end;
    //***********************
  end;

  PosScr1 := ClientToScreen(Btn_Test.BoundsRect.TopLeft);
  Application.ActivateHint(PosScr1);  
end;
Fabricio Araujo
  • 3,810
  • 3
  • 28
  • 43
  • 1
    Docs are misleading, ActivateHint won't activate the hint if *hint control* is not already the control at the specified point. Meaning, it will work if the mouse is over the control. – Sertac Akyuz May 27 '19 at 20:51
  • @SertacAkyuz hmmm. I remember seeing an test of `(FHintControl <> nil)` when I debugged the VCL source. That's why... Any ideas, maybe windows messages? – Fabricio Araujo May 27 '19 at 21:24
  • Anyway, if it's a brick wall - turn that comment in a answer and I'll check it as the the answer. – Fabricio Araujo May 27 '19 at 21:31
  • 4
    You can indirectly set the hint control but AFAICS Application Hint is not meant to be a free style hint. Depending on what you want to achieve, you can use a tooltip control or a custom hint ([e.g.](https://stackoverflow.com/questions/22870464/forcing-a-non-blocking-temporary-hint-window-in-delphi)) or who knows what else... – Sertac Akyuz May 27 '19 at 21:36

0 Answers0