【发布时间】:2010-11-23 12:36:34
【问题描述】:
这应该很简单,但我找不到我想要的确切答案。我有一个基于 TSpeedButton 的自定义 delphi 控件。我希望 SpeedButton 的 Caption 属性始终为“Comments”,但我不想在运行时设置它我想在组件本身中设置它,以便当我将它放在我的表单上时它已经填充了这个文本。我也想设置按钮的高度和宽度,但我想这样做的方法与设置标题的方法相同。
为了完整起见,这里是组件代码:
unit CustomSpeedButton;
interface
uses
SysUtils, Classes, Controls, Buttons;
type
TCustomSpeedButton = class(TSpeedButton)
private
FCommentText: string;
FCommentTitle: string;
procedure SetCommentText(const Value: string);
procedure SetCommentTitle(const Value: string);
{ Private declarations }
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property CommentTitle: string read FCommentTitle write SetCommentTitle;
property CommentText: string read FCommentText write SetCommentText;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Standard', [TCustomSpeedButton]);
end;
{ TCustomSpeedButton }
procedure TCustomSpeedButton.SetCommentText(const Value: string);
begin
FCommentText := Value;
end;
procedure TCustomSpeedButton.SetCommentTitle(const Value: string);
begin
FCommentTitle := Value;
end;
end.
【问题讨论】:
-
您的意思是您希望默认 标题为“评论”,还是您的意思是您希望标题始终 为“评论” , 不管开发者以后改成什么?
-
默认标题为“评论”
标签: delphi properties components custom-component