В: Как сделать анимированный баннер?
О: Так (спасибо El Sanchez)
О: Так (спасибо El Sanchez)
Код:
[Setup]
AppName=test
AppVerName=test
DefaultDirName={tmp}
Uninstallable=no
CreateUninstallRegKey=no
OutputDir=.
[Languages]
Name: ru; MessagesFile: compiler:Languages\russian.isl
[Files]
Source: "giphy.gif"; Flags: dontcopy solidbreak
[Code]
#define A = (Defined UNICODE) ? "W" : "A"
const
WS_CHILD = $40000000;
WS_VISIBLE = $10000000;
WS_DISABLED = $08000000;
// ATL Functions
function AtlAxWinInit: BOOL; external 'AtlAxWinInit@atl.dll stdcall';
function AtlAxCreateControl(lpszName: string; hWnd: HWND; pStream, ppUnkContainer: Longint): HResult; external 'AtlAxCreateControl@atl.dll stdcall';
// Window Functions
function GetSysColor(nIndex: Integer): DWORD; external 'GetSysColor@user32.dll stdcall';
function CreateWindowEx(dwExStyle: DWORD; lpClassName, lpWindowName: string; dwStyle: DWORD; x, y, nWidth, nHeight: Integer; hWndParent: HWND; hMenu: HMENU; hInstance, lpParam: Longint): HWND; external 'CreateWindowEx{#A}@user32.dll stdcall';
function DestroyWindow(hWnd: HWND): BOOL; external 'DestroyWindow@user32.dll stdcall';
var
GIFWndHandle: HWND;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ShowAnimatedGIF(AWndParent: HWND; ALeft, ATop, AWidth, AHeight: Integer; AUrl: string; AColor: TColor): HWND;
(*
Parameters:
AWndParent...: A handle to the parent window
ALeft........: The initial horizontal position of the window
ATop.........: The initial vertical position of the window
AWidth.......: The width of the window
AHeight......: The height of the window
AUrl.........: The URL or full path of the GIF file
AColor.......: Color background
Return value:
A handle to ActiveX control host window
*)
var
HTMLStr: string;
ResultCode: HResult;
begin
if not AtlAxWinInit then Exit;
Result := CreateWindowEx(0, 'AtlAxWin', '', WS_CHILD or WS_VISIBLE or WS_DISABLED, ALeft, ATop, AWidth, AHeight, AWndParent, 0, 0, 0);
if Result = 0 then
RaiseException(SysErrorMessage(DLLGetLastError));
if AColor < 0 then
AColor := GetSysColor(AColor and $0000FF);
HTMLStr := Format('about:<html><body leftmargin="0" topmargin="0" scroll="no" bgcolor="#%.2x%.2x%.2x"><p align="center"><img src="%s" height="100%%"></img></p></body></html>', [AColor and $0000FF, AColor and $00FF00 shr 8, AColor and $FF0000 shr 16, AUrl]);
ResultCode := AtlAxCreateControl(HTMLStr, Result, 0, 0);
if ResultCode <> 0 then
RaiseException(SysErrorMessage(ResultCode));
end;
///////////////////////////
procedure InitializeWizard;
begin
ExtractTemporaryFile('giphy.gif');
GIFWndHandle := ShowAnimatedGIF(WizardForm.SelectDirPage.Handle,
0, WizardForm.DirEdit.Top + WizardForm.DirEdit.Height + ScaleY(5), WizardForm.SelectDirPage.Width, WizardForm.DiskSpaceLabel.Top - WizardForm.DirEdit.Top - WizardForm.DirEdit.Height - ScaleY(5),
ExpandConstant('{tmp}\giphy.gif'), WizardForm.SelectDirPage.Color);
end;
////////////////////////////
procedure DeinitializeSetup;
begin
if GIFWndHandle <> 0 then
DestroyWindow(GIFWndHandle);
end;