根据屏幕分辨率确定 Inno Media Player 视频 window 的 Top 和/或 Left 值

Determine Top and / or Left values of the video window of Inno Media Player according to screen resolution

我写了一个代码来获取屏幕宽高比。问题是代码很长,将来会出现许多新的屏幕分辨率。 这是:

function GetScreenAspectRatio(): Integer;
var
  ScreenResolution: String;
  ScreenAspectRatio: String;
begin
  ScreenResolution := IntToStr(GetSystemMetrics(0)) + 'x' + IntToStr(GetSystemMetrics(1));
  if ScreenResolution = '640x480' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '800x600' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '1024x768' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '1152x864' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '1280x960' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '1400x1050' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '1600x1200' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '2048x1536' then ScreenAspectRatio:= '4:3';
  if ScreenResolution = '3200x2400' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '4000x3000' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '6400x4800' then ScreenAspectRatio := '4:3';
  if ScreenResolution = '852x480' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '1024x576' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '1280x1024' then ScreenAspectRatio := '5:4';
  if ScreenResolution = '1152x648' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '1280x720' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '1366x768' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '1600x900' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '1920x1080' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '2560×1440' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '3840x2160' then ScreenAspectRatio := '16:9';
  if ScreenResolution = '1280x800' then ScreenAspectRatio := '16:10';
  if ScreenResolution = '1440x900' then ScreenAspectRatio := '16:10';
  if ScreenResolution = '1680x1050' then ScreenAspectRatio := '16:10';
  if ScreenResolution = '1920x1200' then ScreenAspectRatio := '16:10';
  if ScreenResolution = '2560x1600' then ScreenAspectRatio := '16:10';
  if ScreenResolution = '3840x2400' then ScreenAspectRatio := '16:10';
  if ScreenResolution = '7680x4800' then ScreenAspectRatio := '16:10';
  MessageBox( WizardForm.Handle, 'Screen Aspect Ratio of Your LapTop / Computer: ' + ScreenAspectRatio, 'GetScreenAspectRatio', MB_OK or MB_ICONWARNING);
end;

消息框仅用于测试目的。我必须使用此输出 ScreenAspectRatio 来确定视频 window.

Top 和/或 Left

但是我不知道如何根据视频分辨率和屏幕分辨率来确定视频Window的Top和/或Left值。

提前致谢。

只需通过从屏幕尺寸中减去视频尺寸来计算屏幕上的剩余 space。并将结果除以二。

var
  Width, Height: Integer;
  Left, Top: Integer;
begin
  ...
  if DSInitializeVideoFile(..., Width, Height, ...) then
  begin
    Left := (GetSystemMetrics(0) - Width) div 2;
    Top := (GetSystemMetrics(1) - Height) div 2;
    ...
  end;
end;