delphivclhintballoon-tip

BalloonHint.ShowHint in Delphi 2010 gets control's hint as title


This is my first time using BalloonHints. I'm using Delphi 2010.

I'm not sure I'm using hints properly because in the following scenario, I get a hint with the same text twice: once as title, once as body. I've struggled for some time with this, also referring to other posts here, Delphi's help, and Cantu's example in D2009 Handbook.

I want my code to pop-up a hint if it detects that the user needs to click a button. And I then want to show the same hint if the user mouses over the button later.

In the following sequence, in step 3, the button's hint text is showing up as the title on the balloon text, as if there's a pipe character...

Step 1: Call ShowHint. The hint appears properly and then disappears properly.

Step 2: User moves mouse over button. The button's hint appears properly.

Step 3: Call ShowHint again. The hint that appears has the proper text from the balloon hint's description, BUT it has a title that is from the button.

Procedure TForm.ShowHintIfNeeded.
var
  Pt: TPoint;
begin
  if fNeedFileName then
  begin
    BalloonHint1.Description := 'Click this button to open';
    Pt.X := btnOpenFile.Width Div 2;
    Pt.Y := 0;
    BalloonHint1.ShowHint(btnOpenFile.ClientToScreen(Pt));
  end;
end;

and my button's dfm:

object btnOpenFile: TBitBtn
  Hint = 'Click this button to open'
  CustomHint = BalloonHint1
  ShowHint = True
end

Solution

  • What if you explicitly set BaloonHint1.Title to nothing, e.g:

    Procedure TForm.ShowHintIfNeeded.
    var
      Pt: TPoint;
    begin
      if fNeedFileName then
      begin
        BalloonHint1.Title := ''; 
        BalloonHint1.Description := 'Click this button to open';
        Pt.X := btnOpenFile.Width Div 2;
        Pt.Y := 0;
        BalloonHint1.ShowHint(btnOpenFile.ClientToScreen(Pt));
      end;
    end;
    

    Does this still show the title as the text from the button?