Detecting mouse clicks on video played with MCI commands

229 views Asked by At

I have an application that plays video. I'm using MCI to play the video and attach it to a panel control. I'm catching mouse clicks on the main form and all the controls, but when I click on the video playing with MCI, it doesn't detect the mouse clicks.

How can you detect mouse clicks on a video played with MCI commands?

1

There are 1 answers

0
iedoc On

I finally got it working by creating a borderless form which i pass in the handle of to the mci video. I set the form TransparencyKey to the backcolor. this way, the video still shows but the mouse clicks are passed through the to main form.

I'm setting the size and location of the form from the main form because for some reason it won't work by setting them from inside the form, which i'm still trying to understand why

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