P
Peted
Hello,
i am lookinf for the best way to trap any alphanumeric keypress in all
multi key combminations and execute some code
For example , i have a form visible using the form.showdialog method,
then the user can press keys A, D, E, F, T, and C to peform a
function.
What i want is that if a user presses A, or a, or SHIFT A or CNTRL A
that it executes the same code, BUT NOT IF ALT A is pressed. The same
applies for the other letters.
I am overriding the processcmdkey function using the code bellow, and
it works, but not for ALL the multi key combo's i present above.
Can anyone help me on how to trap all the key combos i want listed
above
thanks for any help
Peted
#region ProcessCmdKey
protected override bool ProcessCmdKey(ref Message msg, Keys
keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
switch (keyData)
{
case Keys.Tab:
//Do something
return true;
break;
case Keys.F3:
//Do something
return true;
break;
case Keys.A:
//Do something
return true;
case Keys.D:
//Do something
return true;
case Keys.E:
//Do something
return true;
case Keys.F:
//Do something
return true;
case Keys.T:
//Do something
return true;
case Keys.C:
//Do something
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}
i am lookinf for the best way to trap any alphanumeric keypress in all
multi key combminations and execute some code
For example , i have a form visible using the form.showdialog method,
then the user can press keys A, D, E, F, T, and C to peform a
function.
What i want is that if a user presses A, or a, or SHIFT A or CNTRL A
that it executes the same code, BUT NOT IF ALT A is pressed. The same
applies for the other letters.
I am overriding the processcmdkey function using the code bellow, and
it works, but not for ALL the multi key combo's i present above.
Can anyone help me on how to trap all the key combos i want listed
above
thanks for any help
Peted
#region ProcessCmdKey
protected override bool ProcessCmdKey(ref Message msg, Keys
keyData)
{
const int WM_KEYDOWN = 0x100;
const int WM_SYSKEYDOWN = 0x104;
if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
{
switch (keyData)
{
case Keys.Tab:
//Do something
return true;
break;
case Keys.F3:
//Do something
return true;
break;
case Keys.A:
//Do something
return true;
case Keys.D:
//Do something
return true;
case Keys.E:
//Do something
return true;
case Keys.F:
//Do something
return true;
case Keys.T:
//Do something
return true;
case Keys.C:
//Do something
return true;
}
}
return base.ProcessCmdKey(ref msg, keyData);
}