开发者

c# ProcessCmdKey overload, match generic combination

开发者 https://www.devze.com 2022-12-22 14:36 出处:网络
On some control, I want ProcessCmdKey to return true if the keys pressed by the user were ALT and any letter of the alphabet.

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

精彩评论

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