M
ml.guo
Unregistered / Unconfirmed
GUEST, unregistred user!
继承控件并增加属性问题
1、 从Image继承一个新控件,要在新控件上增加(即TFont)一个设置画字体的各种属性
我写了如下,使用时点选Font属性时提示:Can not assign a nil to Tfont.
请各位修改一下:
unit image1;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls,Graphics;
type
timage1 = class(timage)
private
ffont:tfont;
{ Private declarations }
protected
procedure setFont(value:tfont);
{ Protected declarations }
public
{ Public declarations }
published
property Font:tfont read ffont write setfont;
{ Published declarations }
end;
procedure Register;
implementation
procedure timage1.setFont(value:tfont);
begin
ffont:=value;
invaldate;
end;
procedure Register;
begin
RegisterComponents('Samples', [timage1]);
end;
end.
-----------------------------
2、 另外,我想在该新控件上编写上一个控件如Tedit,Tmemo等,应如何编写?
1、 从Image继承一个新控件,要在新控件上增加(即TFont)一个设置画字体的各种属性
我写了如下,使用时点选Font属性时提示:Can not assign a nil to Tfont.
请各位修改一下:
unit image1;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, ExtCtrls,Graphics;
type
timage1 = class(timage)
private
ffont:tfont;
{ Private declarations }
protected
procedure setFont(value:tfont);
{ Protected declarations }
public
{ Public declarations }
published
property Font:tfont read ffont write setfont;
{ Published declarations }
end;
procedure Register;
implementation
procedure timage1.setFont(value:tfont);
begin
ffont:=value;
invaldate;
end;
procedure Register;
begin
RegisterComponents('Samples', [timage1]);
end;
end.
-----------------------------
2、 另外,我想在该新控件上编写上一个控件如Tedit,Tmemo等,应如何编写?