On some control, I want ProcessCmdKey to return true if the keys pressed by the user were ALT and any letter of the alphabet.
I'm able to return true if the user presses Alt with the following code, but how can I add the co开发者_如何学Gondition of a letter also pressed ?
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if ((keyData & Keys.Alt) != 0) {
return true;
}
}
Thanks.
if ((keyData & Keys.Alt) != 0 && (keyData & Keys.KeyCode) >= Keys.A && (keyData & Keys.KeyCode) <= Keys.Z)
xor should work:
if ((keyData & Keys.Alt) == Keys.Alt & (keyData ^ Keys.Alt) != 0) {
return true;
}
精彩评论