【问题标题】:Detecting mouse clicks on video played with MCI commands检测鼠标点击使用 MCI 命令播放的视频
【发布时间】:2014-11-21 04:28:36
【问题描述】:

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

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

【问题讨论】:

  • 如果您将某些东西附加到面板控件,如何处理来自该控件的点击? UI 控件应该能够处理点击。
  • 由于某种原因这行不通。那是我尝试的第一件事,将面板句柄传递给 mci 视频,让该面板捕获鼠标点击,并将其添加到主窗体控件。鼠标单击会遍历整个表单并单击表单后面的任何内容。主窗体永远不会捕捉到鼠标点击

标签: c# mci


【解决方案1】:

我终于通过创建一个无边界表单来让它工作,我将它传递给 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();
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-31
    • 1970-01-01
    • 2020-04-18
    • 1970-01-01
    • 2014-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多