但以上程式可發現
系統時間不會動
此時發現原來 Timer 需持續計數
最後的改良版如下
語法:
'timeGetTime()
'精度約1ms , 此式適用於大多數應用場合
Private Declare Function timeGetTime Lib "winmm.dll" () As Long
Dim TempT As Long
Dim PreText As String
Dim gX As Single, gY As Single
Dim blnMove As Boolean
Private Sub Form_Load()
PreText = Text1
TempT = timeGetTime
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If gX = X And gY = Y Then Exit Sub
gX = X: gY = Y
TempT = timeGetTime
blnMove = True
Text1 = PreText
End Sub
Private Sub Timer1_Timer()
If (timeGetTime - TempT) > 1500 Then '表示1.5秒不動的話...
If blnMove Then
PreText = Text1
blnMove = False
End If
Text1 = Time
End If
End Sub