我在KeyDown事件中获取键盘按下某键,但是出了上下左右四个方向键不能进入这个事件,其它键都能正常进入这个事件中.
代码如下:
void MainForm_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyValue.ToString());
}
我在按其他键的时候都能弹出一个对话框,但是当我按方向键的时候就没有弹出来!!!
代码如下:
void MainForm_KeyDown(object sender, KeyEventArgs e)
{
MessageBox.Show(e.KeyValue.ToString());
}
我在按其他键的时候都能弹出一个对话框,但是当我按方向键的时候就没有弹出来!!!
/// 开始
/// </summary>
public void Start()
{ if (!_isStarted && _hookType != 0)
{
// Make sure we keep a reference to this delegate!
// If not, GC randomly collects it, and a NullReference exception is thrown
_hookCallback = new HookProc(HookCallbackProcedure); _handleToHook = SetWindowsHookEx(
_hookType,//13
_hookCallback,//int
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]),
0); // Were we able to sucessfully start hook?
if (_handleToHook != 0)
{
_isStarted = true;
} } }
这是我下载别人的代码,运行到这里的时候_handleToHook 总是为0,但是我运行下载的那个例子又不为0!!!