111,129
社区成员
发帖
与我相关
我的任务
分享using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Data;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form, IMessageFilter
{
public Form1()
{
InitializeComponent();
Application.AddMessageFilter(this);
}
private int WM_KEYDOWN = 0x0100;
private int WM_KEYUP = 0x0101;
[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
private static extern IntPtr GetParent(IntPtr hWnd);
public bool PreFilterMessage(ref Message msg)
{
if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_KEYUP)
{
if (GetParent(GetParent(GetParent(msg.HWnd))) == webBrowser1.Handle)
{
if (Control.ModifierKeys == Keys.Control && (((Keys)msg.WParam.ToInt32() & Keys.KeyCode) == Keys.C || ((Keys)msg.WParam.ToInt32() & Keys.KeyCode) == Keys.V))
{
MessageBox.Show("屏蔽");
return true;
}
}
}
return false;
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("about:blank");
webBrowser1.Document.ExecCommand("EditMode", false, null);
}
}
}
2、
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Data;
using System.Data.OleDb;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form,IMessageFilter
{
public Form1()
{
InitializeComponent();
Application.AddMessageFilter(this);
}
private int WM_KEYDOWN = 0x0100;
private int WM_KEYUP = 0x0101;
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
public bool PreFilterMessage(ref Message msg)
{
if (msg.Msg == WM_KEYDOWN || msg.Msg == WM_KEYUP)
{
StringBuilder sb = new StringBuilder(50);
GetClassName(msg.HWnd,sb,50);
if (sb.ToString().ToLower() == "internet explorer_server")
{
if (Control.ModifierKeys == Keys.Control && (((Keys)msg.WParam.ToInt32() & Keys.KeyCode) == Keys.C || ((Keys)msg.WParam.ToInt32() & Keys.KeyCode) == Keys.V))
{
MessageBox.Show("屏蔽");
return true;
}
}
}
return false;
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.Navigate("about:blank");
webBrowser1.Document.ExecCommand("EditMode", false, null);
}
}
}