Einzelnen Beitrag anzeigen

Benutzerbild von Jens Schumann
Jens Schumann

Registriert seit: 27. Apr 2003
Ort: Bad Honnef
1.644 Beiträge
 
Delphi 2009 Professional
 
#4

Re: ableiten von klassen und überschreiben von ereignissen

  Alt 12. Okt 2003, 18:56
Hallo,
schau Dir mal dies Beispiel an. Das funktioniert
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type

  TMelder = class(TCustomPanel)
  private
    FZustand : Boolean;
  protected
    procedure Click; override;
  public
    constructor Create(AOwner : TComponent);
  end;

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{ TMelder }

procedure TMelder.Click;
begin
  FZustand:=Not FZustand;
  Case FZustand Of
    False : Color:=clBtnFace;
    True : Color:=clLime;
    end;
  inherited Click;
end;

constructor TMelder.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  ControlStyle := ControlStyle - [csAcceptsControls,csSetCaption];
end;

{ TForm1}

procedure TForm1.FormCreate(Sender: TObject);
var
  MyMelder : TMelder;
begin
  MyMelder:=TMelder.Create(Self);
  MyMelder.Parent:=Self;
  MyMelder.Left:=50;
  MyMelder.Top:=20;
end;

end.
  Mit Zitat antworten Zitat