Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - Change hint font, fontsize and fontcolor

1 Posts
1 Users
0 Reactions
6,138 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2860
Topic starter  

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.

   
ReplyQuote
Share: