home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1999 February
/
PCWorld_1999-02_cd.bin
/
temacd
/
HotKeys
/
AniIcon.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1997-04-11
|
2KB
|
88 lines
unit AniIcon;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, AniIcons;
type
TRepeatCount = 0..MAXINT;
TAnimatedIcon = class(TComponent)
private
FAnimation : TAnimatedIcons;
FPlaying : Boolean;
FRepeatCount: TRepeatCount;
FOnNewFrame : TNewFrameEvent;
FOnStopped : TNotifyEvent;
{ Private declarations }
procedure SetAnimation(Value: TAnimatedIcons);
procedure SetPlaying(Value: Boolean);
protected
procedure NewFrame(Sender: TObject; Frame: Integer);
procedure Stopped(Sender: TObject);
procedure Loaded; override;
{ Protected declarations }
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{ Public declarations }
published
property Playing : Boolean read FPlaying write SetPlaying default False;
property Animation : TAnimatedIcons read FAnimation write SetAnimation;
property RepeatCount: TRepeatCount read FRepeatCount write FRepeatCount default 0;
property OnNewFrame : TNewFrameEvent read FOnNewFrame write FOnNewFrame;
property OnStopped : TNotifyEvent read FOnStopped write FOnStopped;
{ Published declarations }
end;
implementation
constructor TAnimatedIcon.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FAnimation := TAnimatedIcons.Create(is32x32);
FAnimation.OnStopped := Stopped;
FAnimation.OnNewFrame := NewFrame;
FRepeatCount := 0;
FPlaying := False;
end;
destructor TAnimatedIcon.Destroy;
begin
FAnimation.Free;
inherited Destroy;
end;
procedure TAnimatedIcon.Loaded;
begin
inherited Loaded;
if FPlaying and not Animation.Playing then Animation.Play(RepeatCount);
end;
procedure TAnimatedIcon.SetAnimation(Value: TAnimatedIcons);
begin
FAnimation.Assign(Value);
end;
procedure TAnimatedIcon.SetPlaying(Value: Boolean);
begin
if FPlaying<>Value then
begin
FPlaying := Value;
if FPlaying then Animation.Play(RepeatCount) else Animation.Stop;
end;
end;
procedure TAnimatedIcon.Stopped(Sender: TObject);
begin
if Assigned(FOnStopped) then FOnStopped(Self);
end;
procedure TAnimatedIcon.NewFrame(Sender: TObject; Frame: Integer);
begin
if Assigned(FOnNewFrame) then FOnNewFrame(Self, Frame);
end;
end.