unit uGIF;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Windows,
BGRAAnimatedGif;
type
{ TGifView }
TGifView = class(TForm)
Image: TImage;
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
public
PathToGIF: string;
end;
var
GifView: TGifView;
implementation
const
//LWA_COLORKEY = 1;
//LWA_ALPHA = 2;
//LWA_BOTH = 3;
WS_EX_LAYERED = $80000;
GWL_EXSTYLE = -20;
{$R *.lfm}
function SetLayeredWindowAttributes(hWnd: longint; Color: longint;
X: byte; alpha: longint): bool stdcall; external 'USER32';
function SetWindowLongA(hWnd: longint; nIndex: longint;
dwNewLong: longint): longint stdcall; external 'USER32';
function GetWindowLongA(hWnd: longint; nIndex: longint): longint stdcall;
external 'user32';
procedure SetTranslucent(ThehWnd: longint; Color: longint; nTrans: integer);
var
Attrib: longint;
begin
{SetWindowLong and SetLayeredWindowAttributes = API functions}
Attrib := GetWindowLongA(ThehWnd, GWL_EXSTYLE);
SetWindowLongA(ThehWnd, GWL_EXSTYLE, attrib or WS_EX_LAYERED);
{anything with color value color will completely disappear if flag = 1 or flag = 3 }
SetLayeredWindowAttributes(ThehWnd, Color, nTrans, 1);
end;
{ TGifView }
procedure TGifView.FormShow(Sender: TObject);
begin
//SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
Image.Picture.LoadFromFile(PathToGIF);
self.Top:= Application.MainForm.Top + Application.MainForm.Height - Self.Height - 10;
self.Left:= Application.MainForm.Left + Application.MainForm.Width - Self.Width - 10;
end;
procedure TGifView.FormCreate(Sender: TObject);
var
Transparency: longint;
begin
Self.Color := clRed;
Transparency := Self.Color;
SetTranslucent(Self.Handle, Transparency, 0);
PathToGIF:= '';
end;
procedure TGifView.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
//SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NoMove or SWP_NoSize);
end;
end.