sábado, 23 de maio de 2009

Alterando a fonte de um hint

{Para testar este exemplo inclua no seu form alguns componentes. Nestes componentes coloque informações na propriedade Hint de cada componente e altere a propriedade ShowHint para True. unit Unit1; }

interface

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

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure MyShowHint(var HintStr: string;
var CanShow: Boolean;
var HintInfo: THintInfo);
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

// Função que irá alterar a fonte do Hint
procedure TForm1.MyShowHint(var HintStr: string;
var CanShow: Boolean;
var HintInfo: THintInfo);
var i : integer;
begin
for i := 0 to Application.ComponentCount - 1 do
if Application.Components[i] is THintWindow then
with THintWindow(Application.Components[i]).Canvas do
begin
Font.Name := 'Arial';
Font.Size := 18;
Font.Style := [fsBold];
HintInfo.HintColor := clWhite;
end;
end;

// Evento OnCreate do Form
procedure TForm1.FormCreate(Sender: TObject);
begin
// Ativa a função que irá alterar o formato do Hint
Application.OnShowHint := MyShowHint;
end;

Nenhum comentário:

Postar um comentário