RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TApplication.OnShowHint Event

Occurs when the application is about to display the hint window for a Help Hint.

Pascal
property OnShowHint: TShowHintEvent;
C++
__property TShowHintEvent OnShowHint;

Write an OnShowHint event handler to change the appearance and behavior of Help Hints. 

In the event handler, set the HintStr parameter to change the text of the Help Hint. To obtain the text of a hint for a particular control, call the GetLongHint or GetShortHint function, and assign the result to HintStr. 

Use the CanShow parameter to permit or prevent the Help Hint from displaying.

Note: You can also respond to this event using the TApplicationEvents component, which allows you to assign an event handler using the IDE.
 

C++ Examples: 

 

/*
This example uses three speed buttons on a panel. The code 
changes the color, width, and position of the text in the 
Help Hint for the third speed button. Set the ShowHint 
property of each speed button to true and give a value to 
the Hint property of each.  You must declare the DoShow 
method in the type declaration of the form. Once it is 
declared, write the code for the DoShow method in the 
implementation part of the unit. Finally, in the OnCreate 
event handler for the form, assign the method to the 
OnShowHint event of the application.
*/
void __fastcall TForm1::DoShowHint(UnicodeString &HintStr, bool &CanShow, THintInfo &HintInfo)
{
  if (HintInfo.HintControl == SpeedButton3)
  {
    HintInfo.HintColor = clAqua;// Changes only for this hint
    HintInfo.HintMaxWidth = 120; // Hint text word wraps if width is greater than 120
    HintInfo.HintPos.x += SpeedButton3->Width; // Move hint to right edge
  }
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Application->ShowHint = true;
  Application->OnShowHint = DoShowHint;
}

 

Delphi Examples: 

{
This example uses three speed buttons on a panel. The code 
changes the color, width, and position of the text in the 
Help Hint for the third speed button. Set the ShowHint 
property of each speed button to true and give a value to 
the Hint property of each.  You must declare the DoShow 
method in the type declaration of the form. Once it is 
declared, write the code for the DoShow method in the 
implementation part of the unit. Finally, in the OnCreate 
event handler for the form, assign the method to the 
OnShowHint event of the application.
} 

procedure TForm1.DoShowHint(var HintStr: String; var CanShow: Boolean; var HintInfo: THintInfo);
begin
  if HintInfo.HintControl = SpeedButton3 then
  begin
    with HintInfo do
    begin
      HintColor := clAqua;{ Changes only for this hint }
      HintMaxWidth := 120;{Hint text word wraps if width is greater than 120 }
      Inc(HintPos.X, SpeedButton3.Width); { Move hint to right edge }
    end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.ShowHint := True;
  Application.OnShowHint := DoShowHint;
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!