Status Bar Hints

Displaying Hints on the Status Bar

This example is adapted from the OnHint example of the Bcb documentation.

  1. Create an application and set the ShowHint property of the form to True.

  2. Add the necessary controls to the application, including a menu and toolbar(s), if desired.

  3. 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

  4. Add a status bar to the form.

  5. 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. 

  6. In the public section of the form's header, declare the following method:

    void __fastcall DisplayHint(TObject *Sender);

  7. 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);
    }
    //---------------------------------------------------------------------------

  8. Implement the FormCreate() event as follows:
    //---------------------------------------------------------------------------
    void __fastcall TForm1::FormCreate(TObject *Sender)
    {
        Application->OnHint = DisplayHint;
    }
    //---------------------------------------------------------------------------

  9. To test the application, press F9.

 

 Home