![]() |
Videogrösse an Panel anpassen
Hallo,
ich hab mal ne Frage. Ich habe auf meiner Form ein Panel und eine MediaPlayer - Komponente. Es funktioniert auch alles so weit. Aber ein Problem habe ich trotzdem. Ich möchte gerne das Video Zentriert in meinen Panel haben. Jetzt ist es so, dass das Video in der oberen linken ecke angezeigt wird. Und das Videobild ist größer als mein Panel. Also passt mein Videobild nicht auf mein Panel. Kann man das auch irgendwie einstellen???? Mit freundlichn Grüßen Christian18 |
Re: Videogrösse an Panel anpassen
:hi: Habe das hier mal in der DP gefunden ...
Leider kann ich den Beitrag jetzt nicht mehr finden ... aber es funktioniert super ...
Delphi-Quellcode:
function GetRect(Panel: TPanel): TRect;
var Width, Height: Integer; newWidth, newHeight: Single; T: Integer; begin Result := Panel.ClientRect; if not GetSizeInfo(frmDetails.MediaPlayer.FileName, Width, Height) then exit; newWidth := (Width * (Result.Bottom - Result.Top)) / Height; newHeight := (Height * (Result.Right - Result.Left)) / Width; if (newWidth < (Result.Right - Result.Left)) and (newHeight > (Result.Bottom - Result.Top)) then begin T := Round((Result.Right - Result.Left - newWidth) / 2); Inc(Result.Left, T); Dec(Result.Right, 2*T); end else if (newHeight < (Result.Bottom - Result.Top)) and (newWidth > (Result.Right - Result.Left)) then begin T := Round((Result.Bottom - Result.Top - newHeight) / 2); Inc(Result.Top, T); Dec(Result.Bottom, 2*T); end end;
Delphi-Quellcode:
Aufruf mit
// Größe des Videos auslesen
function GetSizeInfo(Name: string; var Width, Height: Integer): Boolean; var dwParam2: TMCI_OVLY_RECT_PARMS; Retval: longint; begin Result := false; dwParam2.dwCallback := MediaPlayer.Handle; dwParam2.rc.Left := 0; dwParam2.rc.Top := 0; dwParam2.rc.Right := 0; dwParam2.rc.Bottom := 0; Retval := mciSendCommand(MediaPlayer.DeviceID,MCI_WHERE, MCI_OVLY_WHERE_SOURCE, integer(@dwParam2)); if Retval <> 0 then exit; Width := dwParam2.rc.Right - dwParam2.rc.Left; Height := dwParam2.rc.Bottom - dwParam2.rc.Top; Result := true; end;
Delphi-Quellcode:
Mediaplayer.FileName:=...videofile...; MediaPlayer.Open; Mediaplayer.DisplayRect:=getRect(VideoPanel); |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:23 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz