所以,我正在使用vb.net
在winform
中设计假病毒应用程序,其中表单的opacity
属性将设置为45
,其background color
将被设置为white
,这会给它一个磨砂的外观,以便看起来计算机已被绞死。
但问题是,当我按Alt+F4
时,它会关闭应用程序,但我希望应用程序仅在按下x
键时关闭,并且我可以通过放置此代码来实现此目的在表单的keydown
事件中。
If e.KeyCode = Keys.X Then
Application.Exit
EndIf
但是,我不知道如何从关闭我的应用程序中禁用Alt+F4
。有没有办法实现这个目标?感谢您提前帮助。
答案 0 :(得分:3)
要停止关闭应用,请使用表单结束事件。它会阻止表单因任何原因而关闭:
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
If (e.CloseReason = CloseReason.UserClosing) Then
e.Cancel = True
End If
End Sub
要使用X键扩展应用程序,请使用keydown事件
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.X Then
Application.Exit
End IF
End Sub
答案 1 :(得分:0)
试试这个:
Private keyPressAltF4 As Boolean = False
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If keyPressAltF4 = True Then
keyPressAltF4 = False
e.Cancel = True
End If
End Sub
Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
keyPressAltF4 = False
If e.Alt = True Then
If e.KeyCode = Keys.F4 Then
e.Handled = True
e = Nothing
keyPressAltF4 = True
End If
End If
End Sub
答案 2 :(得分:0)
我们没有使用我们的软件,请与其他人联系。
<ShiftCardScroller NewDayScrolledIntoView="@((args)=> NewDayInView(args.Item1,args.Item2,args.Item3))" />