Using the Hint Property to Show Contextual Help About Screen Objects

From RAD Studio
Jump to: navigation, search

Go Up to Calling HTML Help from Applications


VCL GUI components like controls support the Hint property, for example, TApplication.Hint and TControl.Hint. Using Hint properties is the recommended way to show contextual help about forms, controls, and other screen objects. Such contextual help about screen objects is also known as "What is this?" help.

Usage of the Hint property is supported by the VCL and IDE.

Note: VCL controls support hint strings containing three parts that can be shown in separate locations. See Vcl.Controls.TControl.Hint.

Setting Hints with VCL

VCL provides the Hint property for many GUI components. The Hint property contains the text string that can appear when the user pauses the mouse pointer over the control.

To enable displaying the Hint's text, set the ShowHint property (Controls.TControl.ShowHint) to True in the code of your form, like in the following code snippet.

Button1.ShowHint := True;                       // show the control's Hint 
Button1.Hint := 'Hint text for the component';  // Hint text

See the ShowHint (Delphi) and ShowHint (C++) examples that demonstrate how to show hints for controls. See the OnHint (Delphi) and OnHint (C++) examples that demonstrate how to show hints in the event handler of the TApplication.OnHint event.

Setting Hints from the Object Inspector

Because the Object Inspector shows the Hint, ShowHint, and other hint managing properties of VCL components, you can provide proper values to these properties directly from the Object Inspector, without any manual editing of your program code.

For instance, the following procedural steps show you how to use the Object Inspector to define several controls on a form that should show hints and to define texts of these hints.

  1. In the Form Designer, select the form you want to customize.
  2. Open the Object Inspector; it shows the properties of your form.
  3. Locate the ShowHint property of the form.
Tip: If you want that most of the controls of the form show Hints, set ShowHint to True on the form. Otherwise, set ShowHint to False.
  1. In the Form Designer, select a component that should show a Hint. The Object Inspector shows the properties of this component.
  2. Locate the ParentShowHint property. Check that its value is True (this is the default).
    When the ParentShowHint property is True, the component takes the ShowHint property from the parent object (that is, from the form). The value of the ShowHint property in the component is ignored.
In your case, the ShowHint property of the parent form is True. This means that the component will show the Hint.
If the ParentShowHint property is False (or ShowHint of the parent form is False), then the value of the ShowHint property in the component is used. If ShowHint is True, then the component will show the Hint.
  1. Locate the Hint property. Click in the value cell of the property and enter the hint text. When entering the hint text, follow the rules in the Vcl.Controls.TControl.Hint.
  2. Use the CustomHint (Vcl.Controls.TControl.CustomHint) and ParentCustomHint properties to customize the appearance of Hints.
  3. Repeat steps 4-7 for all components in the form to define which components should show hints and which should not show them, to define hint texts, and how to show hints.
  4. Build and run the project. Open the form. The intended components will show the specified Hints.

See Also

Code Samples