October 10, 2008

Tips 10


Change font, size and style of hint

Hints are everywhere. Almost every GUI element in Windows can be “hinted”. When user hover mouse over element, small yellow bubble with help text pops up. Is it possible to change hint “window” behavior? Of course…

To see how to change default color and timeouts of hint bubble, visit this post. To change font, size and style of the hint text, just use this code:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

type
TExHint = class(THintWindow)
constructor Create(AOwner: TComponent); override;
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

constructor TExHint.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
with Canvas.Font do
begin
Name := 'Verdana';
Size := Size + 15;
Style := [fsBold, fsItalic];
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
HintWindowClass := TExHint;
end;

end.

0 comments:

Post a Comment

 

Copyright 2008 All Rights Reserved | Blogger Template by Computer Science and Computer Tips