C#中窗体屏蔽键盘按键
2012-11-19 13:20:38 来源:WEB开发网核心提示: 重写Wndproc示例:static bool flag = false; protected override void WndProc(ref Message m) { switch (m.Msg) { case 0x0200: //WM_MOUSEMOVE if (flag) { PostMessage(t
重写Wndproc示例:
static bool flag = false;
protected override void WndProc(ref Message m)
{
switch (m.Msg) {
case 0x0200: //WM_MOUSEMOVE
if (flag)
{
PostMessage(this.Handle, 0x00A1,new IntPtr(2),m.LParam);//这里需要导入 user32.dll
}
break;
case 0x201://WM_LBUTTONDOWN
flag = true;
break;
case 0x202://WM_LBUTTONUP
flag = false;
protected override void WndProc(ref Message m)
{
switch (m.Msg) {
case 0x0200: //WM_MOUSEMOVE
if (flag)
{
PostMessage(this.Handle, 0x00A1,new IntPtr(2),m.LParam);//这里需要导入 user32.dll
}
break;
case 0x201://WM_LBUTTONDOWN
flag = true;
break;
case 0x202://WM_LBUTTONUP
flag = false;
break;
default:
base.WndProc(ref m);
break;
}
base.WndProc(ref m);
break;
}
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
- ››键盘样式风格有关设置
- ››屏蔽 iPhone 3GS 的“语音控制”系统的方法
- ››窗体中字段顺序不同于Access 2007中记录源中字段顺...
- ››键盘流必备 - Windows 7常用快捷键整理之基础篇
- ››键盘流必备 - Windows 7常用快捷键整理之WIN键篇
- ››键盘流必备 - Windows 7常用快捷键整理之任务栏篇...
- ››键盘流必备 - Windows 7常用快捷键整理之资源管理...
- ››键盘极客 - 使用组合键来关闭Windows 7
- ››键盘捕获事件与MessageBox的冲突
- ››窗体中字段顺序不同于 Access 2007 中记录源中字段...
- ››屏蔽五项"鸡肋"网络功能 让XP极速狂飙
- ››键盘的F1到F12键 你究竟会用几个
更多精彩
赞助商链接