惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
F
Fortinet All Blogs
A
About on SuperTechFans
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
P
Proofpoint News Feed
D
Docker
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
I
InfoQ
Recorded Future
Recorded Future
爱范儿
爱范儿
Last Week in AI
Last Week in AI
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
L
LINUX DO - 热门话题
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
CXSECURITY Database RSS Feed - CXSecurity.com
L
Lohrmann on Cybersecurity
The Last Watchdog
The Last Watchdog
V
Visual Studio Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Privacy International News Feed
博客园 - 三生石上(FineUI控件)
Schneier on Security
Schneier on Security
Simon Willison's Weblog
Simon Willison's Weblog
Martin Fowler
Martin Fowler
雷峰网
雷峰网
Latest news
Latest news
Scott Helme
Scott Helme
T
Tenable Blog
Vercel News
Vercel News
宝玉的分享
宝玉的分享
PCI Perspectives
PCI Perspectives
Help Net Security
Help Net Security
L
LINUX DO - 最新话题
Attack and Defense Labs
Attack and Defense Labs
Spread Privacy
Spread Privacy
量子位
H
Heimdal Security Blog

博客园 - Enli

IOS 命令行安装备忘 IOS开发备忘 MAC 编制计划任务 弹出式窗口管理单元备忘 Wininet请求包装类简稿 自备工具库 多屏开发的备忘 界面方面的备忘 rc资源文件的中英文应用备忘 Wininet下载类初稿 Dephi调用C#编写的WebService的一些问题与解决 (转) 关于Window的快捷方式,图标缓存的清理 Delphi 备忘五 http断点续传的单元 Delphi 代码优化(转) [转载]Delphi的四舍五入函数 关于delphi的程序在英文操作系统下乱码问题 - Enli - 博客园 TWebBrowser备忘 组件开发中的技巧(转)
同名派生的应用(转)
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.