7,789
社区成员
发帖
与我相关
我的任务
分享Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 17 Then MsgBox "ctrl"
End Sub
GetKeyState, state, Ctrl
if state = UOption Explicit
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Sub Command1_Click()
Me.Cls
If (GetKeyState(vbKeyControl) And &H8000) Then
Me.Print "Ctrl+单击!"
Else
Me.Print "单击!"
End If
End Sub
② 在设计时,把窗口的 KeyPreview属性设置为True ,然后在Form_KeyDown()、Form_Up()中处理状标识。
这个我就不用写代码了,你应该是会的。
建议用API的方法,这样方便些。