Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I am currently working on a C# Windows Forms Application within Visual Studio Express 2012.

I have a video, which has it's parent set to a Panel the exact same size as the video (Basically a container for the video). What I am after is the video to have a click event handler so a certain function is performed when any area on the video is clicked.

However there does not seem to be a built in Click event handler for the Video object. I have tried a number of ways to get around this including placing a transparent pictureBox and Panel placed on top of the video with its own click event however this does not seem to work.

Can anyone advise me a way around this please?

Many Thanks


---------edit---------

Code shown below as requested. I want to control what happens when video1 is clicked

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media; 
using Microsoft.DirectX.DirectSound; 
using Microsoft.DirectX.AudioVideoPlayback;

namespace videoApplication
{
	public partial class Videos : Form
    {
		Video video1;
		Panel videosPanel;
		
		public Videos()
        {
            InitializeComponent();
        }
		
		private void Videos_Load(object sender, EventArgs e)
		{
			//Get the video file path
		    var vffilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            vffilePath = vffilePath.Substring(0, vffilePath.Length - 15) + "/Video1.wmv";
			
			//Load the video and set parent to panel
			video1 = new Video(filePath);
            video1.Owner = videosPanel;
            video1.Size = new Size(500, 500);
            videosPanel.Size = new Size(500, 500);
			
			//Start playing video automatically
            video1.Play();		
		}
	}
}
Posted
Updated 25-Feb-14 6:00am
v2

1 solution

I would suggest you to look at ContextMenuStrip[^], which represents a shortcut menu for the any control associated with it.

And how to do that, that is pretty simple. You should play around with the property of the control after adding context menu in your application. But still, look at here[^].

A small little tiny example of it is given over here.[^].

Hope this much info could be useful to you.

-KR
 
Share this answer
 
Comments
Member 10334528 25-Feb-14 10:29am    
Krunal Rohit - Thank you for your response. However this seems to be a way of performing the function without the video click event if I've understood this correctly? Although a valid alternative its extremely important that the required function is run when the video is clicked.

Kind Regards
Krunal Rohit 25-Feb-14 10:30am    
Define - Video Click.

-KR
Member 10334528 25-Feb-14 11:00am    
Video Click as in Clicking the left Mouse button while the cursor is resting anywhere on the area of the video. For example when you click anywhere on a video playing on Youtube the video will pause.

Many Thanks
Krunal Rohit 25-Feb-14 11:10am    
Ok, can you post the code of whatever you've done so far.
Paste it in your question. Use 'Improve Question' widget.
Thanks :)

-KR
Member 10334528 25-Feb-14 12:02pm    
KR - I have added the code above, I am not sure how useful this is as alot is done by the VS designer but its video1 that I require the click event on

Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900