在你新的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;

解决方案 »

  1.   

    1).在published 段中加入:property Font;
    2).在protected 段中加入:procedure CMFontChanged(var Message:TMessage);message Cm_FontChanged;
    目的是为了当控件字体改变时,进行响应,具体的程序内容可以根据你程序的不同,自己编制!
      

  2.   

    你可以看vcl的源码,看它是如何作的.
      

  3.   

    Venne:
    你用你的方法试过没有?在设计时改变字体后能存盘吗?
      

  4.   

    如果你的vcl的祖先有Font属性,用startcn的方法就可以.
    如果你的vcl的祖先没有Font属性,可以看vcl的source
    TContorl的实现,把它有关的Font的处理研究一下即可.
    如果你想用自己的Font的对话框,那就复杂了,要涉及到属性编辑器的编写,
    Delphi高级开发指南 一书有很好的讲解.它的配书源码
    www.midatech.com/jiangtao可下载.在第 12 章.
      

  5.   

    这是Tcontorl中Font的定义
    property Font: TFont read FFont write SetFont stored IsFontStored;
    希望有帮助. 
      

  6.   

    radish,  我当然这样做过,为了清楚起见,我下面给出一个非常简单地例子,他使一个IMAGE控件具有FONT属性,而且,因为TFONT的编辑器是在DELPHI中注册过的,所以,用户使用你的属性和别的FONT属性都一样。当然,前面他们提到的我认为应该没问题,但我总喜欢把问题更简单化。
    至于可否存盘的问题,你不妨自己一试。^_^
    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.
      

  7.   

    我今天才注册这个网站,发现你老在这里人缘不错。感觉你在图形方面是不是有特别长处,现请教是否知道RGB到LAB到HSB到YUK到CMYK几种颜色模式的转换,找了很多资料没找到,不知道您那里是否有。我想实现一个像PHOTHOSHOP里使用COLOR模式上色的效果,即给无色的图片(比如一张黑白照片)上色,但是不改变明暗关系和亮度及对比度。不知老兄(姑且这样称呼)在此方面可有心得?如真可以解决,点数您可以开口。(不过,不太希望是到XXXX地下载XXXX),BORLAND的NEWS我也问过,上面提供的站点已迁移。
      

  8.   

    TControl的protected带一个Font属性,直接published一下不就成了吗?
      

  9.   

    感谢venne和参与的各位,我没有自己写SetFont所以不对。
    另:venne,我对图象没有什么研究,不过我可以告诉你borland的news地址:
    forums.inprise.com
    我主要在看win api方面的。