如何从另一个 Sub 使用 KeyEventArgs 调用 Sub
How to call a Sub with KeyEventArgs from another Sub
我有两个潜艇
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
和
Private Sub Form1_KeyPressCaps(ByVal key As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.CapsLock Then
If keyStCL = True Then
checkbutton_caps.Checked = False
checkbutton_caps.Image = My.Resources.Resource1.btn_ico_caps_off
'Image.FromFile("resources\btn_ico_caps_off.png")
keyStCL = False
ElseIf keyStCL = False Then
checkbutton_caps.Checked = True
checkbutton_caps.Image = My.Resources.Resource1.btn_ico_caps_on
'Image.FromFile("resources\btn_ico_caps_on.png")
keyStCL = True
End If
End If
End Sub
我想从 kbHook_KeyDown 呼叫 Form1_KeyPressCaps。我该怎么做。
我试过这个:
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
Call Form1_KeyPressCaps(Key, New KeyEventArgs)
End Sub
但是它不起作用。我收到一个错误:
Argument not specified for parameter 'keyData' of 'Public Sub New(keyData As System.Windows.Forms.Keys)'.
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
Call Form1_KeyPressCaps(Key, New KeyEventArgs(Key))
End Sub
我有两个潜艇
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
和
Private Sub Form1_KeyPressCaps(ByVal key As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.CapsLock Then
If keyStCL = True Then
checkbutton_caps.Checked = False
checkbutton_caps.Image = My.Resources.Resource1.btn_ico_caps_off
'Image.FromFile("resources\btn_ico_caps_off.png")
keyStCL = False
ElseIf keyStCL = False Then
checkbutton_caps.Checked = True
checkbutton_caps.Image = My.Resources.Resource1.btn_ico_caps_on
'Image.FromFile("resources\btn_ico_caps_on.png")
keyStCL = True
End If
End If
End Sub
我想从 kbHook_KeyDown 呼叫 Form1_KeyPressCaps。我该怎么做。
我试过这个:
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
Call Form1_KeyPressCaps(Key, New KeyEventArgs)
End Sub
但是它不起作用。我收到一个错误:
Argument not specified for parameter 'keyData' of 'Public Sub New(keyData As System.Windows.Forms.Keys)'.
Private Sub kbHook_KeyDown(ByVal Key As System.Windows.Forms.Keys) Handles KeyHook.KeyDown
Call Form1_KeyPressCaps(Key, New KeyEventArgs(Key))
End Sub