我已经开始在Delphi 6 Pro中构建一个新组件.目前它只有一个TFont发布的财产.但是,当我在设计时将组件放在Form上,并单击“textAttr_1”属性(省略号)的编辑按钮时,我得到一个异常,说“不能将NIL分配给TFont”.我做错了什么导致了这个错误?以下是组件的代码:
unit JvExtendedTextAttributes; interface uses Windows,Messages,SysUtils,Classes,JvRichEdit,Graphics; type TJvExtendedTextAttributes = class(TComponent) private { Private declarations } protected { Protected declarations } FTextAttr_1: TFont; public { Public declarations } constructor Create(AOwner: TComponent); published { Published declarations } property textAttr_1: TFont read FTextAttr_1 write FTextAttr_1; end; procedure Register; implementation procedure Register; begin RegisterComponents('FAVORITES',[TJvExtendedTextAttributes]); end; // --------------------------------------------------------------- constructor TJvExtendedTextAttributes.Create(AOwner: TComponent); begin inherited Create(AOwner); FTextAttr_1 := TFont.Create; end; // --------------------------------------------------------------- end.