Public Class Form1
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, keyData As Keys) As Boolean
Select Case keyData
Case (Keys.F10 Or Keys.Shift Or Keys.Control)
MessageBox.Show("You pressed Shft+Ctrl+F10.")
Return True
Case (Keys.F10 Or Keys.Control)
MessageBox.Show("You pressed Ctrl+F10.")
Return True
Case Keys.F10
MessageBox.Show("You pressed F10.")
Return True
End Select
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
End Class
Option Strict On
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Location = New Point(CInt((Screen.PrimaryScreen.WorkingArea.Width / 2) - (Me.Width / 2)), CInt((Screen.PrimaryScreen.WorkingArea.Height / 2) - (Me.Height / 2)))
Me.KeyPreview = True
End Sub
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.F10 Then
e.Handled = True
Button2_Click(Me, Nothing)
End If
If e.Control AndAlso e.KeyCode = Keys.B Then
e.Handled = True
Button2_Click(Me, Nothing)
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Button2.Text = ChrW(38) & "Follow"
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
MessageBox.Show("Button2 selected.")
End Sub
End Class
沒有留言:
張貼留言