English 中文(简体)
不使用播放按钮控件调整MediaPlayer的大小
原标题:Resize MediaPlayer without play button controls

我想在没有播放控件的情况下编写一个可调整大小的WindowsMediaplayer(ActiveX)。它应该适合T面板。

最佳回答

不久前我不得不解决这个问题,经过大量的谷歌搜索,我发现这个问题有效

Put a WindowsMedaiPlayer object on the Panel, and setting its align to alclient,
the player control area can be hidden with uiMode := none , set in the ide or code

然后将“面板调整大小”事件指定为

uses Ole2;

procedure TForm1.Panel1Resize(Sender: TObject);
 const
    IID_IOleInPlaceObject: SYSTEM.TGUID =  {00000113-0000-0000-C000-000000000046} ;
 var
  IOIPObj: IOleInPlaceObject;
 begin
  SYSTEM.IDispatch(WindowsMediaPlayer1.OleObject).QueryInterface(IID_IOleInPlaceObject, IOIPObj);
  IOIPObj.SetObjectRects(Panel1.ClientRect, Panel1.ClientRect);
 end;


procedure TForm1.Play;
 begin
  WindowsMediaPlayer1.uiMode :=  none ;  //show no interface, this can be set from the ide
  WindowsMediaPlayer1.URL :=  movie.mpg ;
  WindowsMediaPlayer1.stretchToFit := True;
  WindowsMediaPlayer1.Controls.play;
 end;

改编自http://our.obor.us/node/1999

Ole2是IOleInPlaceObject的,我不得不添加<code>$(Delphi)源代码

(德尔菲7,wmp 11)

额外:更容易使用的东西

uses Ole2; 

procedure SmoothResizeMediaPlayer(aMediaPlayer: TWindowsMediaPlayer; PosRect,ClipRect:Trect);
const
  IID_IOleInPlaceObject: SYSTEM.TGUID =  {00000113-0000-0000-C000-000000000046} ;
var
  IOIPObj: IOleInPlaceObject;
begin
  SYSTEM.IDispatch(aMediaPlayer.OleObject).QueryInterface(IID_IOleInPlaceObject, IOIPObj);
  IOIPObj.SetObjectRects(PosRect, ClipRect);
end;

和呼叫

  SmoothResizeMediaPlayer(WindowsMediaPlayer1, panel1.ClientRect, panel1.ClientRect);
问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签