⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aniicon.pas

📁 Delphi 开发的的热键操作 很值得看的
💻 PAS
字号:
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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -