[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using right click with AxShockwaveFlashObjects.AxShockwaveFlash

Posted on 2009-12-29
2
Medium Priority
?
1,532 Views
Last Modified: 2012-05-08
In my winform app I use the AxShockwaveFlashObjects.AxShockwaveFlash in order to display flash movie.
When the flash movie is playing the right click show the flash movie context menu.
I would like to show my context menu at the right click event instead the  flash movie context menu.
How can I do this?
0
Comment
Question by:yaron89
2 Comments
 
LVL 33

Accepted Solution

by:
Todd Gerbert earned 2000 total points
ID: 26149365
This is the best I could come up with.

I created a class that listens for a right mouse click on a control.  The control whose right mouse you want to catch is passed in the constructor,

rightMouseCatcher = new CatchRightMouseButton(axShockwaveFlash1);

Will cause the CatchRightMouseButton rightMouseCatcher to intercept right mouse button down messages intended for axShockwaveFlash1 and raise an event in your form instead of allowing axShockwaveFlash1 to process the message.

In this simple example I have it showing a message box, but instead you would popup a contextmenu.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
	public partial class Form1 : Form
	{
		private CatchRightMouseButton rightMouseCatcher;

		public Form1()
		{
			InitializeComponent();

			rightMouseCatcher = new CatchRightMouseButton(axShockwaveFlash1);
			rightMouseCatcher.RightMouseClick += new EventHandler(mw_RightMouseClick);
		}

		void mw_RightMouseClick(object sender, EventArgs e)
		{
			MessageBox.Show("Show My Own Menu");
		}
	}

	public class CatchRightMouseButton : NativeWindow
	{
		public event EventHandler RightMouseClick;

		public enum WindowsMessages : int
		{
			WM_LBUTTONDOWN = 0x0201,
			WM_RBUTTONDOWN = 0x0204
		}

		public CatchRightMouseButton(Control parent)
		{
			parent.HandleDestroyed += new EventHandler(parent_HandleDestroyed);
			AssignHandle(parent.Handle);
		}

		void parent_HandleDestroyed(object sender, EventArgs e)
		{
			ReleaseHandle();
		}

		protected virtual void OnRightMouseClick()
		{
			if (RightMouseClick != null)
				RightMouseClick(this, new EventArgs());
		}

		protected override void WndProc(ref Message m)
		{


			switch ((WindowsMessages)m.Msg)
			{
				case WindowsMessages.WM_RBUTTONDOWN:
					OnRightMouseClick();
					break;
				default:
					base.WndProc(ref m);
					break;
			}

		}
	}
}

Open in new window

0
 

Author Closing Comment

by:yaron89
ID: 31670870
Thank you !
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question