如何关闭我的应用程序禁用Alt + F4键 [英] How do I Disable Alt+F4 Key from closing my application

查看:142
本文介绍了如何关闭我的应用程序禁用Alt + F4键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



请如何关闭我的应用程序禁用ALT + F4键。



谢谢

解决方案

处理 Form.FormClosing [ ^ ]事件并设置 e.Cancel = true 。也许请查看 CloseReason [ ^ ]: - )


这是在C#中,但应该很容易改变。



说实话这是一个黑客攻击



在表格上声明会员var

私人布尔ALT_F4 =假; 





处理表单结束事件

  private   void  Form1_FormClosing( object  sender,FormClosingEventArgs e)
{
if (ALT_F4)
{
e.Cancel = true ;
return ;
}
}





处理表格上的按键事件

< pre lang =cs> private void Form1_KeyDown( object sender,KeyEventArgs e)
{
ALT_F4 =(e.KeyCode.Equals(Keys.F4)&& e.Alt == 真的);
}





代码转换



将C#转换为VB.NET [< a href =http://www.developerfusion.com/tools/convert/csharp-to-vb/\"target =_ blanktitle =新窗口> ^ ]


获得钥匙的最佳方式是





if(e.KeyCode ==(Keys)115)

{

//按ALT + F4

}


Hi everyone,

Please how do I disable the ALT + F4 Key from closing my application.

Thanks

解决方案

Handle Form.FormClosing[^] event and set e.Cancel = true. And perhaps check CloseReason[^] :-)


This is in C#, but should be easy enough to alter.

It is a bit of a hack to be honest

Declare a member var on the form

private bool ALT_F4 = false;



Handle the form closing event

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
  if (ALT_F4)
  {
    e.Cancel = true;
    return;
  }
}



Handle the key down event on the form

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
  ALT_F4 =(e.KeyCode.Equals(Keys.F4) && e.Alt == true) ;
}



For Code conversion

Convert C# to VB.NET[^]


Best Ways to get key is


if (e.KeyCode == (Keys)115)
{
//ALT + F4 pressed
}


这篇关于如何关闭我的应用程序禁用Alt + F4键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆