KeyEventArgs.Handled vs KeyEventArgs.SupressKeyPress

后端 未结 2 1212
天命终不由人
天命终不由人 2020-12-16 02:46

What\'s the difference between using

e.Handled = true

and

e.SuppressKeyPress = true

I\'ve read that Sup

2条回答
  •  佛祖请我去吃肉
    2020-12-16 03:44

    According to this blog: New keyboard APIs: KeyEventArgs.SuppressKeyPress:

    The problem is that "Handled" doesn't take care of pending WM_CHAR messages already built up in the message queue - so setting Handled = true does not prevent a KeyPress from occurring.

    In order not to break anyone who has currently got e.Handled = true, we needed to add a new property called SuppressKeyChar. If we went the other way, if "handling" a keydown suddenly started to actually work, we might break folks who accidentally had this set to true.

提交回复
热议问题