Answered how to disable special keys in windows application using c#

  • 13 เมษายน 2555 10:10
     
     
    i want to disable ctrl+alt+delete, windows, shift, ctrl, alt, delete, esc,tab,alt+tab, alt+f4 keys in windows application using c#

    <Kabilan>Learning C#</Kabilan>

ตอบทั้งหมด

  • 13 เมษายน 2555 17:41
     
     

    Take a look at this tutorial. This will only work when your form is in focus. If you want to intercept them even when your form is minimized, you'll need to get a bit more fancy.

  • 14 เมษายน 2555 1:45
     
     คำตอบ มีโค้ด

    hi,

    r u working in WPF or windows application. if it is WPF then u can use the following override code and customize according to ur requirements

     protected override void OnPreviewKeyDown(KeyEventArgs e)
            {
                if (Keyboard.Modifiers == ModifierKeys.Alt && e.SystemKey == Key.F4 ||
                   Keyboard.Modifiers == ModifierKeys.Control && e.SystemKey == Key.Escape)
                {
                    e.Handled = true;
                }
                else
                {
                    base.OnPreviewKeyDown(e);
                }
                
            }

    hope u get the solution

    regards

    Jagan

    • ทำเครื่องหมายเป็นคำตอบโดย kabilan kabi 14 เมษายน 2555 2:26
    •  
  • 14 เมษายน 2555 2:26
     
     
    Thank you jagan

    <Kabilan>Learning C#</Kabilan>

  • 14 เมษายน 2555 13:25
     
     

    Hi,

    as a user, I wouldn't want to use an application which tries to do that to my computer! You are trying to disable important functions of the operating system, and no honest program should do that...


    http://wpfglue.wordpress.com

  • 16 เมษายน 2555 6:36
     
     

    But it handles only once... i need to handle this every time user press these keys... help me


    <Kabilan>Learning C#</Kabilan>