WEB开发网
开发学院WEB开发ASP.NET C#中窗体屏蔽键盘按键 阅读

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;
                break;
         default:
           base.WndProc(ref m);
           break;
       }
    [DllImport("user32.dll", CharSet = CharSet.Unicode)]
     public static extern IntPtr PostMessage(IntPtr hwnd, int wMsg, IntPtr wParam, IntPtr lParam);
 
 
 

1 2 3  下一页

Tags:窗体 屏蔽 键盘

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接