To change the font of a hint window, we do need to implement a new hint window handler class, which sounds complicated, but really isn't since we inherit almost everything from the original class. (source)
This can be useful, for example, to adapt the font to the style of your application, or when you'd like to use a fixed width font in your hint window, so you can line text out.
Example code (enter a caption and hint for label1 and set ShowHint to TRUE):
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TExtendedHint = class(THintWindow)
constructor Create(AOwner: TComponent); override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor TExtendedHint.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
with Canvas.Font do
begin
Name := 'Courier New';
Size := 13;
Style := [fsBold, fsItalic]; // just an example
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HintWindowClass := TExtendedHint;
end;
end.