在你新的VCL中声明一个属性:
property Font:TFont;{剩下的可以由DELPHI的类补全帮你做好,应该增加一个TFONT类的FFONT对象}
然后,在你的控件的构造中加一句:
constructor TYourComponent.Create(AOwner:TComponent);
begin
inherited;
FFont:=TFont.Create;
end;
在你的其它实现中使用这个对象的属性,就和其它DELPHI的控件一样,
在析构你的控件时,一定记住先释放FFONT对象:
destructor TYourComponent.Destroy;
begin
FFont.Free;
inherited;
end;
property Font:TFont;{剩下的可以由DELPHI的类补全帮你做好,应该增加一个TFONT类的FFONT对象}
然后,在你的控件的构造中加一句:
constructor TYourComponent.Create(AOwner:TComponent);
begin
inherited;
FFont:=TFont.Create;
end;
在你的其它实现中使用这个对象的属性,就和其它DELPHI的控件一样,
在析构你的控件时,一定记住先释放FFONT对象:
destructor TYourComponent.Destroy;
begin
FFont.Free;
inherited;
end;
2).在protected 段中加入:procedure CMFontChanged(var Message:TMessage);message Cm_FontChanged;
目的是为了当控件字体改变时,进行响应,具体的程序内容可以根据你程序的不同,自己编制!
你用你的方法试过没有?在设计时改变字体后能存盘吗?
如果你的vcl的祖先没有Font属性,可以看vcl的source
TContorl的实现,把它有关的Font的处理研究一下即可.
如果你想用自己的Font的对话框,那就复杂了,要涉及到属性编辑器的编写,
Delphi高级开发指南 一书有很好的讲解.它的配书源码
www.midatech.com/jiangtao可下载.在第 12 章.
property Font: TFont read FFont write SetFont stored IsFontStored;
希望有帮助.
至于可否存盘的问题,你不妨自己一试。^_^
unit fontImage;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;type
TfontImage = class(TImage)
private
FCaption: String;
FFont: TFont;
procedure SetCaption(const Value: String);
procedure SetFont(const Value: TFont);
{ Private declarations }
procedure DrawCaption;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner:Tcomponent);override;
destructor Destroy;override;
published
{ Published declarations }
property Font:TFont read FFont write SetFont;
property Caption:String read FCaption write SetCaption;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Samples', [TfontImage]);
end;{ TfontImage }constructor TfontImage.Create(AOwner: Tcomponent);
begin
inherited;
FFont:=TFont.Create ;
end;destructor TfontImage.Destroy;
begin
FFont.Free ;
inherited;
end;procedure TfontImage.DrawCaption;
begin
With Canvas do begin
font:=FFont;
textOut(0,0,FCaption);
end;
end;procedure TfontImage.SetCaption(const Value: String);
begin
FCaption := Value;
DrawCaption;
end;procedure TfontImage.SetFont(const Value: TFont);
begin
FFont.Assign (Value);
DrawCaption;
end;end.
另:venne,我对图象没有什么研究,不过我可以告诉你borland的news地址:
forums.inprise.com
我主要在看win api方面的。