By:wgscd
flash的右键菜单有时候需要屏蔽。主要就是消息预处理,代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TestFlash
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
#region Disable Flash's Context Menu
private const int GWL_WNDPROC = -4;
public delegate IntPtr FlaWndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
private IntPtr OldWndProc = IntPtr.Zero;
private FlaWndProc Wpr = null;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, FlaWndProc wndProc);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr CallWindowProc(IntPtr wndProc, IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
private IntPtr FlashWndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)
{
if (msg == 516)
return (IntPtr)0;
return CallWindowProc(OldWndProc, hWnd, msg, wParam, lParam);
}
#endregion
private void Form2_Load(object sender, EventArgs e)
{
this.Wpr = new FlaWndProc(this.FlashWndProc);
this.OldWndProc = SetWindowLong(axShockwaveFlash1.Handle, GWL_WNDPROC, Wpr);
axShockwaveFlash1.Movie = "C://test.swf";
axShockwaveFlash1.Play();
}
}
}
另外在VS2005里添加FLASH控件一时候不可以,BUG处理这里有个方法:http://blogs.vbcity.com/drydo/archive/2005/12/07/5731.aspx
关闭VS2005,复制“AxInterop.ShockwaveFlashObjects.dll”这个到Debug下
重新试验成功!