Einzelnen Beitrag anzeigen

Aviator

Registriert seit: 3. Jun 2010
1.611 Beiträge
 
Delphi 10.3 Rio
 
#24

AW: Neue Komponente entwickeln

  Alt 25. Aug 2017, 09:23
Habe gerade mal ausgehend von Detlef's Beispiel im Editor was zusammengeschrieben. Sollte eigentlich funktionieren. Eventuell ist noch der ein oder andere Syntaxfehler drin, aber den bekommst Du dann denke ich aufgelöst.

Delphi-Quellcode:
type
  TSiloZelle = class(TGraphicControl)
  private
    FIsEmpty: Boolean;
  protected
    procedure Paint; override;
    procedure SetIsEmpty(Value: Boolean); virtual;
    function GetIsEmpty: Boolean; virtual;
  public
    //...
    property Canvas;
    property IsEmpty: Boolean read GetIsEmpty write SetIsEmpty;
  //...
  end;


procedure TSiloZelle.Paint;
begin
  inherited;

  DoSomePaintStuff();

  if IsEmpty then
    Canvas.Brush.Color := clRed
  else
    Canvas.Brush.Color := clGreen;

  DoSomeOtherPaintStuff();
end;

procedure SetIsEmpty(Value: Boolean);
begin
  FIsEmpty := Value;
  Self.Invalidate;
end;

function GetIsEmpty: Boolean;
begin
  Result := FIsEmpty;
end;
  Mit Zitat antworten Zitat