Inno Setup 最大化启动视频

Inno Setup Maximize splash video

我正在使用 TLama 的 Inno Media Player 在设置开始时显示启动视频。

因此我使用以下代码:

[Code]
const
  EC_COMPLETE = ;

type
  TDirectShowEventProc = procedure(EventCode, Param1, Param2: Integer);

function DSGetLastError(var ErrorText: WideString): HRESULT;
  external 'DSGetLastError@files:mediaplayer.dll stdcall';
function DSPlayMediaFile: Boolean;
  external 'DSPlayMediaFile@files:mediaplayer.dll stdcall';
function DSStopMediaPlay: Boolean;
  external 'DSStopMediaPlay@files:mediaplayer.dll stdcall';
function DSInitializeVideoFile(FileName: WideString; WindowHandle: HWND; var Width,
  Height: Integer; CallbackProc: TDirectShowEventProc): Boolean;
  external 'DSInitializeVideoFile@files:mediaplayer.dll stdcall';

var
  VideoForm: TSetupForm;

procedure OnMediaPlayerEvent(EventCode, Param1, Param2: Integer); 
begin
  if EventCode = EC_COMPLETE then
    VideoForm.Close;
end;

procedure OnVideoFormShow(Sender: TObject);
var
  ErrorCode: HRESULT;
  ErrorText: WideString; 
  Width, Height: Integer;
  begin
  if DSInitializeVideoFile(ExpandConstant('{tmp}\{#MyVideo}'), VideoForm.Handle, Width, 
    Height, @OnMediaPlayerEvent) then
  begin
    VideoForm.ClientWidth := Width;
    VideoForm.ClientHeight := Height;
    DSPlayMediaFile;
  end
  else
  begin
    ErrorCode := DSGetLastError(ErrorText);
    MsgBox('TDirectShowPlayer error: ' + IntToStr(ErrorCode) + '; ' + 
      ErrorText, mbError, MB_OK);
  end;
end;

procedure OnVideoFormClose(Sender: TObject; var Action: TCloseAction);
begin
  DSStopMediaPlay;
end;

procedure InitializeWizard;
begin
ExtractTemporaryFile('{#MyVideo}');

  VideoForm := CreateCustomForm;
  VideoForm.Position := poScreenCenter;
  VideoForm.OnShow := @OnVideoFormShow;
  VideoForm.OnClose := @OnVideoFormClose;
  VideoForm.FormStyle := fsStayOnTop;
  VideoForm.Caption := 'Popup Video Window';
  VideoForm.ShowModal;

end;

procedure DeinitializeSetup;
begin
  DSStopMediaPlay;
end;

现在想问问有没有可能把视频最大化window。

提前致谢

使用 ShowWindowSW_SHOWMAXIMIZED 标志来最大化 window。

DSInitializeVideoFileWidthHeight 参数的输入值中接受所需的视频大小。

因此,如果您在开始播放视频之前显示并最大化 window,则可以传递最大化 window 的大小。

类似于:

function ShowWindow(hWnd: DWord; nCmdShow: Integer): Boolean;
  external 'ShowWindow@user32.dll stdcall';

procedure OnVideoFormShow(Sender: TObject);
var
  Width: Integer;
  Height: Integer;
  VideoForm: TForm;
begin
  VideoForm := TForm(Sender);

  ShowWindow(VideoForm.Handle, SW_SHOWMAXIMIZED);

  Width := VideoForm.ClientWidth;
  Height := VideoForm.ClientHeight;

  if not DSInitializeVideoFile(ExpandConstant('{tmp}\{#MyVideo}'), VideoForm.Handle,
    Width, Height, @OnMediaPlayerEvent) then
  begin
    VideoForm.Close;
  end;
end;

procedure InitializeWizard;
begin
  VideoForm := CreateCustomForm;
  ...
  VideoForm.ShowModal;
end;