Inno Setup最大化启动视频

时间:2015-09-26 15:15:31

标签: video inno-setup pascalscript

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

因此我使用以下代码:

[Code]
const
  EC_COMPLETE = $01;

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;

现在我想询问是否有可能最大化视频窗口。

提前致谢

1 个答案:

答案 0 :(得分:1)

使用带有SW_SHOWMAXIMIZED标记的ShowWindow来最大化窗口。

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

因此,如果您在启动视频之前显示并最大化窗口,则可以传递最大化窗口的大小。

类似的东西:

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;