Einzelnen Beitrag anzeigen

Benutzerbild von Alexander Roth
Alexander Roth

Registriert seit: 17. Mai 2004
Ort: Kenn
574 Beiträge
 
Turbo Delphi für Win32
 
#1

Ereignis zu TJvLED hinzufügen

  Alt 25. Dez 2006, 10:11
Hallo und frohe Weihnachten,

also ich habe mit Komponentenprogrammierung noch so gut wie keine Erfahrung.
Nun will ich von der Komponente TJvLED (eine Jedi Kompo) eine Komponente ableiten, die zusätzlich das Ereignis OnColorChange (also wenn die Farbe geändert wird) besitzt.

Dazu erstmal den Code von TJvLED
Delphi-Quellcode:
  TJvCustomLED = class(TJvGraphicControl)
  private
    FImgPict: TBitmap;
    FImgMask: TBitmap;
    FTimer: TTimer;
    FColorOn: TColor;
    FColorOff: TColor;
    FActive: Boolean;
    FStatus: Boolean;
    FOnChange: TNotifyEvent;
    {$IFDEF VisualCLX}
    FAutoSize: Boolean;
    procedure SetAutoSize(Value: Boolean);
    {$ENDIF VisualCLX}
    procedure SetColorOn(Value: TColor);
    procedure SetColorOff(Value: TColor);
    procedure SetInterval(Value: Cardinal);
    function GetInterval: Cardinal;
    procedure SetActive(Value: Boolean);
    function GetActive: Boolean;
    procedure SetStatus(Value: Boolean);
    function GetStatus: Boolean;
    procedure DoBlink(Sender: TObject);
  protected
    procedure ColorChanged; override;
    procedure Paint; override;
    property Active: Boolean read GetActive write SetActive default False;
    property Color default clLime;
    property ColorOn: TColor read FColorOn write SetColorOn default clLime;
    property ColorOff: TColor read FColorOff write SetColorOff default clRed;
    property Interval: Cardinal read GetInterval write SetInterval default 1000;
    property Status: Boolean read GetStatus write SetStatus default True;
    {$IFDEF VisualCLX}
    property AutoSize: Boolean read FAutoSize write SetAutoSize;
    {$ENDIF VisualCLX}
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  end;

  TJvLED = class(TJvCustomLED)
  published
    property Active;
    property Align;
    property Anchors;
    property AutoSize;
    {$IFDEF VCL}
    property DragCursor;
    property DragKind;
    property OnEndDock;
    property OnStartDock;
    {$ENDIF VCL}
    property ColorOn;
    property ColorOff;
    property Constraints;
    property DragMode;
    property Height default 17;
    property Interval;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property Status;
    property Visible;
    property Width default 17;
    property OnClick;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDrag;
  end;
Dann habe ich:
Delphi-Quellcode:
  TALED=class(TJVLED)
  private
    FOnColorChange:TNotifyEvent;
  protected
    procedure ColorChanged;
  published
    property OnColorChange:TNotifyEvent read FOnColorChange write FOnColorChange;
  end;
und
Delphi-Quellcode:
procedure TALED.ColorChanged;
begin
  inherited ColorChanged;

  if Assigned(FOnColorChange) then
     FOnColorChange(self);
end;
doch es wird kein Ereignis ausgelöst.
Habe ich die falsche Procedure zum auslösen des Ereignisses gewählt?
Wo wird dann die Farbe geändert?

Hoffe ihr könnt mir helfen.

MFG und frohe Feiertage

Alexander
Alexander Roth
Ich bin umgestiegen auf: Lazarus und Ubuntu! Alles OpenSource!

Besuch doch mal: www.roth.us.ms
  Mit Zitat antworten Zitat