RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TApplication.OnHint Event

Occurs when the mouse pointer moves over a control or menu item that can display a Help Hint.

Pascal
property OnHint: TNotifyEvent;
C++
__property TNotifyEvent OnHint;

Write an OnHint event handler to perform special processing when the mouse pauses over a control or menu item whose Hint property is not an empty string.  

A common use of the OnHint event is to display the value of a control or menu item's Hint property in another control. Note that it is not necessary to use an OnHint event handler to display hints on a status bar (TStatusBar): TStatusBar will automatically display hints if you set its AutoHint property to true. 

The Hint property of a control can specify both a short Help Hint and a (usually) longer hint that appears elsewhere because of code in an OnHint event handler.

Note: You can also respond to this event using the TApplicationEvents component, which allows you to assign an event handler using the IDE.
Tip: Component writers can respond to the automatically-fired THintAction action in a component's ExecuteAction method rather than relying on an OnHint event handler.
 

C++ Examples: 

 

/*
Note:   It is not actually necessary to write an OnHint
event handler to display hints on the status bar. This can
be accomplished more simply by setting the status bar’s
AutoHint property and SimplePanel property.
This shows how the OnHint event handler is declared as a
public method of the form.
*/

/*
Here is the code to add to the unit file.  It provides the
implementation of the DisplayHint method and assigns it to
the Application in the form’s OnCreate event handler.
Note:   It is not actually necessary to write an OnHint event
handler to display hints on the status bar. This can be
accomplished more simply by setting the status bar’s AutoHint
property.
*/
void __fastcall TForm1::DisplayHint(TObject *Sender)
{
  StatusBar1->SimpleText = GetLongHint(Application->Hint);
}

// Here is the form’s OnCreate event handler.
// It assigns the application’s OnHint event handler at
// runtime because the Application is not available in the
// Object Inspector
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Application->OnHint = DisplayHint;
}

 

Delphi Examples: 

{
Note:   It is not actually necessary to write an OnHint
event handler to display hints on the status bar. This can
be accomplished more simply by setting the status bar’s
AutoHint property and SimplePanel property.
This shows how the OnHint event handler is declared as a
public method of the form.
}
type
  TForm1 = class(TForm)
    Button1: TButton;
    StatusBar1: TStatusBar;
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    procedure DisplayHint(Sender: TObject);
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}

{ Here is the implementation of the OnHint event handler }
{ It displays the application’s current hint in the status bar }
procedure TForm1.DisplayHint(Sender: TObject);
begin
  StatusBar1.SimpleText := GetLongHint(Application.Hint);
end;
{ Here is the form’s OnCreate event handler. }
{ It assign’s the application’s OnHint event handler at runtime }
{ because the Application is not available in the Object Inspector }
{ at design time }
procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnHint := DisplayHint;
end; 

 

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