[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Forms' (#lcl)

# THintWindow.CalcHintRect

Determines the display rectangle needed the specified hint text.

## Declaration

Source position: forms.pp line 1022

`public function THintWindow.CalcHintRect(`
`MaxWidth: Integer;`
`const AHint: string;`
`AData: pointer`
`):TRect; virtual;`

## Arguments

`MaxWidth` |  | Maximum width for the hint display when greater than zero, otherwise the full monitor width is used.
`AHint` |  | Hint text used to calculate the display area.
`AData` |  | Pointer to additional data used to construct the hint text. Mot used in the method.

## Function result

Display area needed for the hint display.

## Description

CalcHintRect is a TRect function used to determine the display rectangle required for the hint window.

MaxWidth indicates the maximum width for the hint window (in pixels) after hint borders and spacing are applied. If MaxWidth is 0 (zero) or a negative number, the width for the Monitor where the Top and Left coordinates are located is used. The value excludes any space needed for borders and spacing on the hint window.

AHint contains the hint text displayed in the Window.

AData is a Pointer to additional data used to construct the hint text displayed in the window. Please note that AData is not used in the current implementation. An overridden ActivateHintData method (in a descendent class) can be used for the purpose though.

The return value is a TRect instance which contains the Top, Left, Right, and Bottom screen coordinates for the client area in the hint window. An empty rectangle (0, 0, 0, 0) is returned when AHint is an empty string ('').

CalcHintRect automatically scales the hint window when Scaled is enabled for both the Application and the form instance, and when PixelsPerInch in the hint window does not match the PixelsPerInch capability for the target Monitor. The width for the text in AHint is calculated using the hint window font, and the Right and Bottom members in the return value are updated accordingly.

Use the ActivateHint method to display the hint window using the coordinates in the return value.

Example usage:

    HintWindow := THintWindow.Create(nil);
    Rect := HintWindow.CalcHintRect(0,'This is the hint', Nil);
    HintWindow.ActivateHint(Rect,'This is the hint');

## See also

THintWindow.ActivateSub |  | Sets the bounds for the hint window and configures the auto-hide timer.
THintWindow.ActivateHint |  | Shows the hint window with the specified hint text.
TApplication.Scaled |  | Indicates if forms and controls in the application can be scaled to different display densities (Pixels per Inch).
TCustomDesignControl.Scaled |  | Indicates if the design surface is scaled to reflect changes in display density (Pixels Per Inch).
Application |  | The TApplication singleton.
TScreen.MonitorFromPoint |  | Finds the monitor containing the given screen coordinates.
TScreen.Monitors |  | Provides indexed access to the available monitors in the class instance.
Screen |  | The TScreen singleton for the application.