winform技巧—去掉Flash右键菜单

#region 去掉Flash右键菜单,API函数的声明


        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)   //516就是对应鼠标的右键,当然你也可以用0X0204右键鼠标的16进制编码


                return (IntPtr)0;   //什么都不做


            return CallWindowProc(OldWndProc, hWnd, msg, wParam, lParam);


        }


        #endregion


你可能感兴趣的:(api,user,Flash,null,WinForm)