我继承了TImage,需要在IMAGE上显示一行文字,因此增加了两个属性
property DataCaption:string read FDataCaption write SetDataCaption;//标题
property DataCaptionFont:TFont read FDataCaptionFont write SetDataCaptionFont;//标题字体然后在Create事件中
constructor TImageEX.Create(AOwner: TComponent);
begin
FDataCaptionFont:=TFont.Create;
FDataCaptionFont.Color:=clBlue;
FDataCaptionFont.Size:=12;
FDataCaptionFont.Name:='宋体'; inherited Create(AOwner);
...
这样控件放置在窗体上时默认显示的字体是蓝色宋体。可是,我把窗体里的DataCaptionFont属性改为红色或其它颜色,设计状态下的颜色也改过来了,但是运行起来后,该字体却返回默认的蓝色字体了,必须手工设置一下颜色才变回来。到底是哪里错了?
property DataCaption:string read FDataCaption write SetDataCaption;//标题
property DataCaptionFont:TFont read FDataCaptionFont write SetDataCaptionFont;//标题字体然后在Create事件中
constructor TImageEX.Create(AOwner: TComponent);
begin
FDataCaptionFont:=TFont.Create;
FDataCaptionFont.Color:=clBlue;
FDataCaptionFont.Size:=12;
FDataCaptionFont.Name:='宋体'; inherited Create(AOwner);
...
这样控件放置在窗体上时默认显示的字体是蓝色宋体。可是,我把窗体里的DataCaptionFont属性改为红色或其它颜色,设计状态下的颜色也改过来了,但是运行起来后,该字体却返回默认的蓝色字体了,必须手工设置一下颜色才变回来。到底是哪里错了?
begin
inherited Create(AOwner); { call inherited constructor } FDataCaptionFont:=TFont.Create;
FDataCaptionFont.Color:=clBlue;
FDataCaptionFont.Size:=12;
FDataCaptionFont.Name:='宋体';
...
关注...