Multi Line Popup Hints for Delphi VCL and FMX

Learn how to setup multi line popup hints in Delphi for any type of control for both VCL and FireMonkey.
This uses native Delphi code.  You don’t need to hack the forms’s DFM text file


Take a short cut … download and use

Cant be bothered reading all this stuff ?
Just do this

  1. Download my utility units for VCL and FireMonkey.
    See the download link at the bottom of the page.
  2. Add a “~” character in your hint text.
    It will be replaced at runtime with a new line
  3. Then include this magic code in your form’s OnCreate event.
  SetupMultiLineHintAll (self);

One line of code .. .easy !

Read on if you want to geek out on the full details

The gory detail

This technique uses a flag character in the hint text (I like to use the tilde character ‘~’) that is replaced at runtime with an ASCII new line character (ASCII #10)

This is what it looks like in the IDE


This magic code will change the ~ character to a new line character

  Button1.Hint := AnsiReplaceStr (
                         '~',   // replace this
                         #10    // with this

So now when you hover over the button the popup hint text will show in multiple lines like this


Generic Procedure

Instead of hard coding for one button, you can use a generic procedure that will work for any type of control.

These procedure will work in both VCL and FMX.
You just have to USE different units, as mentioned in the comments

procedure SetupMultiLineHint (aComponent : TComponent);
 // setup multi line hints for a single control
 // For VCL: uses VCL.controls, System.StrUtils
 // For FMX: uses FMX.controls, System.StrUtils
 s : string;
 if aComponent is TControl then
    s := AnsiReplaceStr (TControl(aComponent).Hint ,'~',#10);
    if TControl(aComponent).Hint <> s then
       TControl(aComponent).Hint := s;

UPDATE – Thanks To Mike for the bug report about TMenuItems not working (see comments below).  Mike’s recommended changes have been implemented above

Then call it like this

  SetupMultiLineHint (Button1);
  SetupMultiLineHint (Button2);
  SetupMultiLineHint (Edit1);
  SetupMultiLineHint (Label1);

Apply To All Controls In A Form

The above example required you to specify each control.

You can can go one step further with a generic procedure that will setup multi-line hints for all controls on your form

procedure SetupMultiLineHintAll (
           aComponent : TComponent // form,frame,button,label,panel
 // setup multi line hints for a component and all child components
 // convert all ~ characters in hints a new line/
 // For VCL uses VCL.controls,System.Classes
 //             ,VCL.Forms,System.StrUtils;
 // For FMX uses FMX.controls,System.Classes
 //             ,FMX.Forms,System.StrUtils;
 i : Integer;
 if (aComponent is TControl) then // form and frame hint
    SetupMultiLineHint (aComponent as TControl);

     // Loop through all the components on the form
     // This finds components anywhere on the form
     // even within panels, tabs and frames
 for i := 0 to aComponent.ComponentCount -1 do
     if aComponent.Components [i] is TFrame then
        SetupMultiLineHintAll (aComponent.Components [i] as TFrame)
        SetupMultiLineHint (aComponent.Components [i] as TControl);

Then call it like this from the form’s OnCreate event

  SetupMultiLineHintAll (self);

Trouble Shooting

  • Popup hints do not display for TLabels in FireMonkey Delphi 10.1 Berlin)
    I think this is a bug in 10.1 FMX.  It has nothing to do with multi-line hints as it occurs with just one line of text
  • #10 doesnt work
    #10 should work on all platforms, but I havent been able to test that due to my Mac Book being temporarily out of action.
    If it doesnt work, try the old trick of using all combinations of #10 and #13
    #10 + #13
    #13 + #10


You can also implement multi-line hints by modifying the text version of the form.  Zarco Gajic explains how to do that here


This includes one unit for VCL and another for FMX.
Tested on Delphi 10.1 Berlin

To implement it, use this code in your forms OnCreate event

  SetupMultiLineHintAll (self);

+1 this post

I am trying to get this blog listed on
If you like this post, please +1 for me here on Delphi Feeds

and here on BeginEnd

Thank You !

About The Author

The Usual Suspect
– Scott Hollows –

  • Oracle and Delphi software developer.
  • Australian Delphi User Group – Western Australia Chief Cat Herder
  • Australian Delphi User Group – President
blog email linkedinlogo

Published by

4 responses to “Multi Line Popup Hints for Delphi VCL and FMX”

  1. Might want to add a check for the else otherwise items like TMenuItems will throw a runtime error.

    for i := 0 to aComponent.ComponentCount -1 do
    if aComponent.Components [i] is TFrame then
    SetupMultiLineHintAll (aComponent.Components [i] as TFrame)
    else if aComponent.Components[i] is TControl then
    SetupMultiLineHint (aComponent.Components [i] as TControl);

  2. Thanks Mike. Good point

    I did further tests and found it also had problems with TAction, TActionList ,TMainMenu ,TMenuItem, TPopupMenu. The hint property lives in TControl and all of those descend from TComponent not TControl so I need to handle that.

    Ive updated the SetupMultiLineHint procedure to deal with this.

    It now accepts a component (instead of a control) and it checks to see if it is a control before modifying the hint.

    -== Scott

  3. Thank you so much Scott. You really helped me.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: