wpf阻止键盘快捷键alt+space,alt+F4

2021-04-20 08:25

阅读:520

原文:wpf阻止键盘快捷键alt+space,alt+F4

   ///


        /// 阻止 alt+f4和alt+space 按键
        ///

        ///
        protected override void OnKeyDown(System.Windows.Input.KeyEventArgs e)
        {
            if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.Space)
            {
                e.Handled = true;
            }
            else if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.F4)
            {
                e.Handled = true;
            }
            else
            {
                base.OnKeyDown(e);
            }
        }


评论


亲,登录后才可以留言!