ProcessKeyPreview in a UserControl works fine to intercept most of the
keys. But I would like to suppress some keys.
private Keys keyMultiply = Keys.Multiply;
....
....
protected override bool ProcessKeyPreview(ref
System.Windows.Forms.Message msg)
{
if (msg.Msg == WM_KEYDOWN)
{
if ((Int32)msg.WParam == (Int32)_keyPrintOrder)
{
MessageBox.Show("*");
return true;
}
}
return base.ProcessKeyPreview(ref msg);
}
When the active control is for example a textbox * will get to it
before MessageBox.Show is being shown. How come? How to suppress keys
in UserControl?
Thanks
MH
carl.henrik.bache@gmail.com - 27 Jun 2007 10:28 GMT
try handle the KeyDown event.
private void test_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyCode == Keys.Multiply)
e.Handled=true;
}
Calle
:-)
> ProcessKeyPreview in a UserControl works fine to intercept most of the
> keys. But I would like to suppress some keys.
[quoted text clipped - 26 lines]
>
> MH