OOP Delphi

Title: How to develope a new component
unit BlackLabel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TBlackLabel = class(TLabel)
private
{ Private declarations }
protected
{ Protected declarations }
public
constructor Create(aOwner: TComponent); override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TBlackLabel]);
end;
constructor TBlackLabel.Create;
begin
inherited Create(aOwner);
Color := clBlack;
Font.Color := clWhite;
end;
This unit create a component that has a black background and white text.
override means, that we will override the constructor of TLabel
inherited means, that the code of TLabel will executed
Now you need a bitmap for your new component, that will displayed in the
component palette
5. Start the Image Editor
6. File-New-Component Resource File
7. Add a new bitmap to the file
8. The bitmaps name must be the component name. In this example TBlackLabel
9. After drawing the bitmap save the Resource file.
10. The resource file must have the same name like the components unit. In this
example blacklabel.dcr
11. The dcr file must be in the same directory like the component unit
12. Install now the component by clicking Component-Install Component
end