我终于通过创建一个无边界表单来让它工作,我将它传递给 mci 视频的句柄。我将表单 TransparencyKey 设置为背景色。这样,视频仍然显示,但鼠标点击通过到主窗体。
我正在从主表单设置表单的大小和位置,因为由于某种原因,从表单内部设置它们不起作用,我仍在尝试理解为什么
public VideoForm()
{
this.FormBorderStyle = FormBorderStyle.None;
this.TransparencyKey = Color.White;
this.TopMost = true;
}
public void PlayVideo(int width, int height, ScreenControl control)
{
string mciCommand = string.Format("open \"{0}\" Type mpegvideo alias {1} parent {2} style child", control.Location(), control.Name, this.Handle.ToString());
int error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero);
mciCommand = string.Format("put {0} window at 0 0 {1} {2}", control.Name, width, height);
error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero);
mciCommand = string.Format("seek {0} to 0", control.Name);
error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero);
mciCommand = string.Format("play {0} repeat", control.Name);
error = WinApi.mciSendString(mciCommand, null, 0, IntPtr.Zero);
this.Show();
}