C#屏蔽flash右键菜单

C#屏蔽flash右键菜单   <script src="http://blog.csdn.net/count.aspx?ID=2036795&Type=Rank" type="text/javascript"></script>

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下

重新试验成功! 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值