This example is adapted from the OnHint example of the
Bcb documentation.
-
Create an application and set the ShowHint
property of the form to True.
-
Add the necessary controls to the application,
including a menu and toolbar(s), if desired.
-
For each control and menu item, add a hint like
the syntax: Short Hint | Status Bar Message
The Short Hint in our example will display when the user positions the
mouse on the control or item. The other string will display on the
status bar.
For example, if an Edit box is used for a first name, type First
Name | Type your first name in Uppercase
If a menu item is called New, you can set its Hint property as New
| Create a new graphic
A button used for printing and positioned on a toolbar could have Print
| Print the current picture
-
Add a status bar to the form.
-
Add as many panels as desired to the status bar.
To show that you can display the control's hint on any panel on the
status bar, the following example, for illustration purposes, uses a
status that has two panels: 0 - StatusPanel and 1 - TStausPanel.
-
In the public section of the form's header,
declare the following method:
void __fastcall DisplayHint(TObject *Sender);
-
In the source file of the form, implement the
DisplayHint() method as follows:
//---------------------------------------------------------------------------
void __fastcall TForm1::DisplayHint(TObject *Sender)
{
StatusBar1->Panels->Items[1]->Text =
GetLongHint(Application->Hint);
}
//---------------------------------------------------------------------------
|
-
Implement the FormCreate() event as follows:
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Application->OnHint = DisplayHint;
}
//---------------------------------------------------------------------------
|
-
To test the application, press F9.
|