我有一个播放视频的应用程序。我正在使用 MCI 播放视频并将其附加到面板控件。我在主窗体和所有控件上捕捉到鼠标点击,但是当我点击使用 MCI 播放的视频时,它不会检测到鼠标点击。
如何检测鼠标点击使用 MCI 命令播放的视频?
我终于通过创建一个无边界表单来让它工作,我将它传递给 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();
}