检测使用 MCI 命令播放的视频上的鼠标单击

本文关键字:鼠标 单击 的视频 播放 MCI 命令 检测 | 更新日期: 2023-09-27 18:31:30

>我有一个播放视频的应用程序。我正在使用 MCI 播放视频并将其附加到面板控件。我在主窗体和所有控件上捕获鼠标单击,但是当我单击使用 MCI 播放的视频时,它不会检测到鼠标单击。

如何检测使用 MCI 命令播放的视频上的鼠标点击?

检测使用 MCI 命令播放的视频上的鼠标单击

我终于通过创建一个无边框表单来让它工作,我将其传递给 mci 视频的句柄。我将表单 TransparencyKey 设置为背景色。这样,视频仍然显示,但鼠标单击通过 To 主窗体传递。

正在从主表单设置表单的大小和位置,因为由于某种原因,它无法通过从表单内部设置它们来工作,我仍在尝试理解为什么

    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();
    }