The space key doesn't have a message id. If you're looking for key down event, WM_KEYDOWN is defined as 0x100. Once you get that message, you can examine the wParam to check if it's 0x20 (Space key).
But you should be able to do all this directly from .Net events without having to fall back on WndProc. Could you describe your problem a bit, so we can help better
Trying the same in the KeyDown event of the control directly also leaves spaces for the spacebar presses. That is the reason I was trying to get space prior to this.
Thanks for your speedy response. I have a custom control something like grid, I would like to avoid space key in that so I inherit it and trying to override WndProc. Here is the code.
WndProc Msg ID
Jef Bernhardt
Try this:
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
e.Handled = true;
base.OnKeyDown(e);
}
CarlVerret
But you should be able to do all this directly from .Net events without having to fall back on WndProc. Could you describe your problem a bit, so we can help better
Fudd
Trying the same in the KeyDown event of the control directly also leaves spaces for the spacebar presses. That is the reason I was trying to get space prior to this.
Thanks again in advance.
INTPnerd
Hi Vijaye,
Thanks for your speedy response. I have a custom control something like grid, I would like to avoid space key in that so I inherit it and trying to override WndProc. Here is the code.
protected override void WndProc(ref Message m)
{
if(m.Msg == 0x100 && m.WParam == 0x20 )// (space)
{
return;
}
base.WndProc (ref m);
}
This is not the right way, can you help me to trap the space key and use WParam in the right way.
Thanks.