After long searches on the Internet, with the information I found, I created this code to change the hint font size of my control. But when I try to assign Message.HintInfo.HintWindowClass:=HintWin;
it give me error: E2010 Incompatible types: 'THintWindowClass' and 'THintWindow'. If I try to typecast THintWindowClass(HitWin)
I get access violation. What should I do ?
In this similar question, Remy Lebeau says: "To change the layout of the hint, you can derive a new class from THintWindow and assign that class type to the THintInfo.HintWindowClass field.".... But I do not understand what he meant.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMyButton = class(TButton)
protected
HintWin: THintWindow;
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
MyButton: TMyButton;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
MyButton:=TMyButton.Create(Form1);
MyButton.Parent:=Form1;
MyButton.Caption:='Test';
MyButton.Left:=100;
MyButton.Top:=100;
MyButton.ShowHint:=true;
end;
constructor TMyButton.Create(AOwner: TComponent);
begin
inherited;
HintWin:=THintWindow.Create(self);
HintWin.Canvas.Font.Size:=24;
end;
destructor TMyButton.Destroy;
begin
HintWin.Free;
inherited;
end;
procedure TMyButton.CMHintShow(var Message: TCMHintShow);
begin
inherited;
Message.HintInfo.HintWindowClass:=HintWin;
Message.HintInfo.HintStr:='My custom hint';
end;
end.