菜鸟学开发 VCL 控件 => 请问如何继承其属性和修改控件的样式?(20分)

  • 主题发起人 主题发起人 Cheasy
  • 开始时间 开始时间
C

Cheasy

Unregistered / Unconfirmed
GUEST, unregistred user!
TLabel2 继承其 TLabel.
目标:(创建 TLabel2)
1. 将 AutoSize 属性默认 True 改为 False.
2. 从控件在创建的时候,在左边有一条红色的边线.

就两个,学习目的是: 修改源属性,和在create时如何调用方法...

unit Label2;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls;

type
TLabel2 = class(TLabel)
private
{ private declarations}
protected
{ Protected declarations }
public
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
published
{...}
end;
procedure Register;

implementation

procedure Register;
begin
RegisterComponents('Standard', [TLabelView]);
end;

{构造}
constructor TLabelView.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
end;

{析构}
destructor TLabelView.Destroy;
begin
inherited Destroy;
end;
end.

请指教~ 谢谢大家!
 
constructor TLabelView.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
Autosize:=False;
end;

procedure Paint;
begin
inherited ;
//画红线

 
接受答案了.
 

Similar threads

后退
顶部