1. Technology

Select Which Panel Displays AutoHint in Delphi's TStatusBar


Select Which Panel Displays AutoHint in Delphi's TStatusBar

Select Which Panel Displays AutoHint in Delphi's TStatusBar

The TStatusBar Delphi control displays a row of panels, usually aligned at the bottom of a form. The Panels property of the TStatusBar control is a collection of TStatusPanel objects.

The AutoHint specifies whether the status bar’s text is set automatically to the current hint.

When AutoHint is true, the status bar automatically responds to hint actions by displaying the long version of the hint’s text in the first panel.

On Hints

Every Delphi control exposes the Hint property. Hint contains the text string that can appear when the user moves the mouse over the control. If Hint contains only one value, the entire string is used as a Help Hint and returned by the GetLongHint function. If two string values, separated by a "|" (pipe) character - GetLongHint can be used to to obtain the long version of the hint specified as the value of a Hint property. Here's an example:

Control.Hint := 'Short hint|Long version of this hint';

GetShortHint returns "Short hint". GetLongHint returns "Long version of this hint"

Display (Auto) Hint in a Specific Panel of a Status Bar!

If you want the current hint to be displayed in some other panel, as needed per your application design (something else displayed in the first panel) you might want to display auto hints in some other panel of a status bar.

Hanlde the OnHint event of the status bar, read the Application.Hint property to get the hint; and finally display the hint in a different panel:

 //Handles StatusBar's OnHint to
 //display AutoHint in the second panel
 procedure THintForm.StatusBar1Hint(Sender: TObject) ;
   //make sure StatusBar1's AutoHint = true
   StatusBar1.Panels[1].Text := Application.Hint;
Note: When AutoHint is true and the status bar needs to display a hint, it generates an OnHint event. If the status bar has an OnHint event handler, then the status bar assumes that the event handler displays the hint and does not set the panel text to the value of the application’s current hint. If there is no OnHint event handler (and AutoHint is true), the status bar displays the text of the hint in the first panel.

Delphi tips navigator:
» How to Refresh a DBGrid without Losing the Current Row Position
« Take a Screen Shot of an Inactive Window - Using PrintWindow API from Delphi

©2014 About.com. All rights reserved.