| 
 
 
{
 1. Create a new compoent by clicking on File->New->Component
 
 2. Select the ancestor type. In this example TLabel
 
 3. Press okay
 
 4. Edit the unit with this code:
 
 }
 
 {
 
 1. Erstelle eine neue Komponente indem sie auf Datei->Neu->Komponente klicken
 
 2. Selektieren sie den Vorfahrtyp. In diesem Beispiel TLabel
 
 3. Drücken sie okay
 
 4. Ändern sie die Unit mit diesem Code:
 
 }
 
 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
 
 }
 
 {
 Diese Unit erstellt eine Komponente mit schwarzem Hintergrund und weisser Schrift
 
 Der Befehl override ist, damit Delphi weiss, dass wir den constructor von TLabel
 mit unserer neuen Komponente überschreiben.
 
 Der Befehl inherited ist, damit die Befehle vom Vorfahrtyp TLabel ausgeführt
 werden.
 
 Jetzt brauchen wir noch ein Bitmap das in der Komponenten Palette angezeigt werden
 soll.
 
 5. Starten sie den Bildeditor
 
 6. Datei->Neu->Komponenten Ressourcen Datei
 
 7. Fügen sie ein neues Bitmap zu der Datei hinzu
 
 8. Der Name der Bitmap muss gleich sein wie der Komponenten Name. In unserem
 Beispiel TBlackLabel
 
 9. Nach dem der Bitmap gezeichnet wurde, speichern sie die Datei
 
 10. Die Ressourcen Datei muss den gleichen Namen haben wie die Komponenten Unit.
 In unserem Beispiel blacklabel.dcr
 
 11. Die dcr Datei muss im gleichen Verzeichnis sein wie die Komponenten Unit.
 
 12. Installieren Sie nun die Komponenten mit Komponente->Komponente installieren
 
 }
 
 end.
 
 
 
   
   
    | 
         
          | Bewerten Sie diesen Tipp: |  |  |