- 积分
- 2468
- 明经币
- 个
- 注册时间
- 2007-9-23
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2018-12-4 17:10:34
|
显示全部楼层
异常捕捉本身就是功能的一部分,人家设计就是按Esc产生错误,再者循环内检测按键都可以
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Const VK_ESCAPE = &H1B
Public Const VK_LBUTTON = &H1
Public Const VK_RBUTTON = &H2
Public Const VK_SPACE = &H20
Public Const PI As Double = 3.14159265358979
Public Function CheckKey(lngKey As Long) As Boolean
If GetAsyncKeyState(lngKey) Then
CheckKey = True
Else
CheckKey = False
End If
End Function
用时是这样的
Call CheckKey(VK_ESCAPE) '消除上一次命令按的取消键
Do Until m_Enabled = False
str = VLF.Item("cursor").funcall()
If CheckKey(VK_ESCAPE) = True Then
RaiseEvent Move(KeyBoard, vbKeyEscape, p)
Exit Sub
End If
temp = Split(str, " ")
If UBound(temp) > 1 Then
p(0) = Val(temp(1))
p(1) = Val(temp(2))
p(2) = Val(temp(3))
End If
RaiseEvent Move(temp(0), temp(1), p)
Loop
|
|