怎么将空格键禁用掉??
private void StopButton()
{
foreach (Control ctr in panel1.Controls)
{
//ctr.KeyPress+=new KeyPressEventHandler(ctr_KeyPress);
ctr.KeyDown+=new KeyEventHandler(ctr_KeyDown);
}
}
private void ctr_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
e.Handled = false;
}
}
private void ctr_KeyPress(object sender,KeyPressEventArgs e)
{
if (e.KeyChar == 32)
{
e.Handled = true;
}
}
------解决方案--------------------这是哥们在用的东西,我已经用这个键盘钩子做了一个键盘统计程序了,在每天上万次的调用下也没出问题,所以给楼主看看,这也是我从csdn大神那里看到的
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using hook;
namespace hook
{
public partial class Form1 : Form