在网上长时间搜索后,根据我找到的信息,我创建了这段代码来更改我的控件的提示字体大小。但是当我尝试分配Message.HintInfo.HintWindowClass:=HintWin;
它时给我错误:E2010 不兼容的类型:'THintWindowClass' 和'THintWindow'。如果我尝试进行类型转换THintWindowClass(HitWin)
,我会遇到访问冲突。我应该怎么办 ?
在这个类似的问题中,Remy Lebeau 说:“要更改提示的布局,您可以从 THintWindow 派生一个新类并将该类类型分配给 THintInfo.HintWindowClass 字段。”....但我不明白他的意思的意思。
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.