Einzelnen Beitrag anzeigen

Benutzerbild von joachimd
joachimd

Registriert seit: 17. Feb 2005
Ort: Weitingen
679 Beiträge
 
Delphi 12 Athens
 
#6

Re: Suche eine "StarWars-Credits"-Komponente :(

  Alt 18. Mär 2005, 13:15
Zitat von Master_RC:
naja, ich brauch ja nur ne ganz billige, die MUSS doch einer haben
eine ganz billige?
Code:
unit Acknowledgement;

interface

uses
  SysUtils, Classes, Controls,extctrls;

type
  TAcknowledgement = class(TPanel)
  private
    FInterval: integer;
    FLines: TStrings;
    procedure SetInterval(const Value: integer);
    procedure SetLines(const Value: TStrings);
    { Private declarations }
  protected
    { Protected declarations }
    timer:TTimer;
    loop:integer;
    idx:integer;
    Procedure OnTimer(Sender: TObject);
    procedure Paint; override;
    procedure SetEnabled(Value: Boolean); override;
  public
    { Public declarations }
    constructor Create(AOwner:TComponent); override;
  published
    { Published declarations }
    property Interval:integer read FInterval write SetInterval;
    property Lines: TStrings read FLines write SetLines;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Joachim', [TAcknowledgement]);
end;

{ TAcknowledgement }


{ TAcknowledgement }

constructor TAcknowledgement.Create(AOwner: TComponent);
begin
  inherited;
  FInterval:=50;
  timer:=TTimer.Create(self);
  timer.Name:='timer'+Name;
  timer.Interval:=FInterval;
  timer.Enabled:=(Finterval>0) and (Enabled);
  timer.OnTimer:=OnTimer;
  FLines:=TStringList.Create;
  Caption:='';
  DoubleBuffered:=true;
end;

procedure TAcknowledgement.OnTimer(Sender: TObject);
begin
  inc(loop);
  Invalidate;
end;

procedure TAcknowledgement.Paint;
var
  x,y:integer;
  idx2:integer;
  ispace:integer;
  s:string;
begin
  Caption:='';
  inherited;
  try
    ispace:=(Font.size+5);
    if (loop>ispace)
      then begin
        loop:=0;
        inc(idx);
        idx:=idx mod FLines.Count;
      end;
    y:=0-loop;
    idx2:=idx;
    while (y<(self.Height+ispace)) do
      begin
        idx2:=idx2 mod FLines.Count;
        s:=FLines[idx2];
        x:=(Width-canvas.TextExtent(s).cx) div 2;
        Canvas.TextOut(x,y,s);
        y:=y+ispace;
        inc(idx2);
      end;
  except
  end;
end;
       
procedure TAcknowledgement.SetEnabled(Value: Boolean);
begin
  inherited;
  if assigned(timer)
    then timer.Enabled:=((Finterval>0) and (Enabled));
end;

procedure TAcknowledgement.SetInterval(const Value: integer);
begin
  FInterval := Value;
  if assigned (timer)
    then begin
      timer.Interval:=FInterval;
      timer.Enabled:=(Finterval>0) and (Enabled);
    end;
end;

procedure TAcknowledgement.SetLines(const Value: TStrings);
begin
  FLines.Assign(Value);
end;

end.
Joachim Dürr
Joachim Dürr Softwareengineering
http://www.jd-engineering.de
  Mit Zitat antworten Zitat