开发者

c# ProcessCmdKey overload, match generic combination

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;
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜