同名派生的应用(转)
Enli
·
2011-02-12
·
via 博客园 - Enli
有时候,我们需要少量修改或增加已有控件的行为或属性,但又不想新写个控件注册到组件面板上或动态创建来用,可以通过同名控件派生来实现。 以下这个简单的例子,为 TPanel 增加了 OnPaint 事件: |
按上面的方法,也可以这样。unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls; type TSpeedButton = class(TButton) public constructor Create(Aowner: TComponent); override; end; TForm1 = class(TForm) SpeedButton1: TSpeedButton; private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} { TSpeedButton } constructor TSpeedButton.Create(Aowner: TComponent); begin inherited Create(AOwner); Caption := 'TSpeedButton to TButton'; end; end. |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。