急!TImage控件中默认字体显示的问题(200分)

J

jacklin

Unregistered / Unconfirmed
GUEST, unregistred user!
我继承了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);
...
这样控件放置在窗体上时默认显示的字体是[blue]蓝色[/blue]宋体。可是,我把窗体里的DataCaptionFont属性改为[red]红色[/red]或其它颜色,设计状态下的颜色也改过来了,但是运行起来后,该字体却返回默认的[blue]蓝色[/blue]字体了,在点击图形的时候,会触发标题重写事件,此时颜色才变回[red]红色[/red]。
到底是哪里错了? 有哪里需要注意的么?
 
J

jacklin

Unregistered / Unconfirmed
GUEST, unregistred user!
还有,在设计状态下,把DataCaptionFont属性前的+号展开,直接改color属性,不会触发SetDataCaptionFont事件??必须要点击DataCaptionFont属性后面的三个点,在字体属性页里点确定才能触发SetDataCaptionFont事件。
 

新世纪

Unregistered / Unconfirmed
GUEST, unregistred user!
在SetDataCaptionFont中, 最后加上刷新显示就应该可以了
 
J

jacklin

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TImageEX.SetDataCaptionFont(const Value: TFont);
begin
FDataCaptionFont.Assign(Value);
do
ButtonStateChange;
end;
有的,在DoButtonStateChange中触发重写动作。
 

Similar threads

S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
顶部