public bolPauseFlag as booleanbolPauseFlag=True 定时器 Private Sub timPause_Timer() bolPauseFlag = False End Sub在函数中调用 timPause.interval=mmm,,你想要的延时时间 While bolPauseFlag DoEvents Wend bolRowOrColFlag = True
Dim OldT as SingleOldT=Timer Do Until Timer-OldT>1 '延时一秒 DoEvents Loop
doEvent 什么东西?是不是拼错了?
如果我的IF语句在 Private Sub Timer1_Timer() 中怎么办,好象会影响下一个方块
在Private Sub Timer1_Timer()中 如何利用Timer1.interval延迟时间?
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)....IF 条件为真 then sleep 1000 (毫秒) 函数1 end if
sleep函数不行,它是使整个程序停止一段时间! 而其他的如键盘,鼠标都不能响应!
Counter为随机产生的方块 FK1(0),FK1(1),FK1(2),FK1(3)分别为方块“坐标”,即图片框的Index 在游戏中每行10个图片框,共21行,(Image2控件数组) 比如第一行 1,2,3.....10 Image1为方块颜色 还有就是当方块停止不动时,图片框的tag为1,当tag为0时,可以移动 GOGO函数是调用下一个方块Private Sub Timer1_Timer() ' *************************** 方块自动下落 ******* If Counter = 1 Then ' *********** NO.1 长条 *********** For i = 0 To 3 Image2(FK1(i)).Picture = Image1(0).Picture Next i For i = 0 To 3 FK1(i) = FK1(i) + 10 Next i For i = 0 To 3 Image2(FK1(i)).Picture = Image1(1).Picture ' 向下移一行 Next i If FK1(0) > 200 Or FK1(1) > 200 Or FK1(2) > 200 Or FK1(3) > 200 Then Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方 Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 GoGo Exit Sub End If If Image2(FK1(0) + 10).Tag = 1 Or Image2(FK1(1) + 10).Tag = 1 Or Image2(FK1(2) + 10).Tag = 1 Or Image2(FK1(3) + 10).Tag = 1 Then Image2(FK1(0)).Tag = 1 ' ***** 判断方块下方是否还有方块 Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 GoGo Exit Sub End If End If If Counter = 2 Then ...... end sub 谢谢~~~~~~~~~~
'你要是这么写呢 Private Sub Timer1_Timer() ' *************************** 方块自动下落 ******* If Counter = 1 Then ' *********** NO.1 长条 *********** For i = 0 To 3 Image2(FK1(i)).Picture = Image1(0).Picture Next i If FK1(0) - 10 >= 0 And FK1(1) - 10 >= 0 And FK1(2) - 10 >= 0 And FK1(3) - 10 >= 0 Then For i = 0 To 3 Image2(FK1(i) - 10).Picture = Image1(1).Picture ' 向下移一行 Next i End If If FK1(0) > 129 Or FK1(1) > 129 Or FK1(2) > 129 Or FK1(3) > 129 Then PauseTime = 2 ' 设置暂停时间。 Start = Timer Do While Timer < Start + PauseTime DoEvents Loop Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方 Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 GoGo Exit Sub End If If Image2(FK1(0) + 10).Tag = "1" Or Image2(FK1(1) + 10).Tag = "1" Or Image2(FK1(2) + 10).Tag = "1" Or Image2(FK1(3) + 10).Tag = "1" Then PauseTime = 2 ' 设置暂停时间。 Start = Timer Do While Timer < Start + PauseTime DoEvents Loop Image2(FK1(0)).Tag = 1 ' ***** 判断方块下方是否还有方块 Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 GoGo Exit Sub End If For i = 0 To 3 FK1(i) = FK1(i) + 10 Next i End If If Counter = 2 Then End If End Sub
If ooo Then ElseIf FK1(0) > 200 Or FK1(1) > 200 Or FK1(2) > 200 Or FK1(3) > 200 Then Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方 ****** Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 sndPlaySound "DOWN.WAV", &H1 GoGo Exit Sub End If If Image2(FK1(0) + 10).Tag = 1 Or Image2(FK1(1) + 10).Tag = 1 Or Image2(FK1(2) + 10).Tag = 1 Or Image2(FK1(3) + 10).Tag = 1 Then Image2(FK1(0)).Tag = 1 ' ******* 判断方块下方是否还有方块 ****** Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 sndPlaySound "DOWN.WAV", &H1 GoGo Exit Sub End If End If
上边是Form_KeyDown timer1 If FK1(0) > 200 Or FK1(1) > 200 Or FK1(2) > 200 Or FK1(3) > 200 Then PauseTime = 15 ' 设置暂停时间。 Start1 = Timer ooo = True Do While Timer < Start1 + PauseTime DoEvents Loop ooo = False Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方 ****** Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 sndPlaySound "DOWN.WAV", &H1
GoGo Exit Sub End If If Image2(FK1(0) + 10).Tag = 1 Or Image2(FK1(1) + 10).Tag = 1 Or Image2(FK1(2) + 10).Tag = 1 Or Image2(FK1(3) + 10).Tag = 1 Then PauseTime = 15 ' 设置暂停时间。 Start1 = Timer ooo = True Do While Timer < Start1 + PauseTime DoEvents Loop ooo = False Image2(FK1(0)).Tag = 1 ' ******* 判断方块下方是否还有方块 ****** Image2(FK1(1)).Tag = 1 Image2(FK1(2)).Tag = 1 Image2(FK1(3)).Tag = 1 sndPlaySound "DOWN.WAV", &H1 GoGo Exit Sub End If
延时函数上Option ExplicitPrivate Type FILETIME dwLowDateTime As Long dwHighDateTime As Long End TypePrivate Const WAIT_ABANDONED& = &H80& Private Const WAIT_ABANDONED_0& = &H80& Private Const WAIT_FAILED& = -1& Private Const WAIT_IO_COMPLETION& = &HC0& Private Const WAIT_OBJECT_0& = 0 Private Const WAIT_OBJECT_1& = 1 Private Const WAIT_TIMEOUT& = &H102&Private Const INFINITE = &HFFFF Private Const ERROR_ALREADY_EXISTS = 183&Private Const QS_HOTKEY& = &H80 Private Const QS_KEY& = &H1 Private Const QS_MOUSEBUTTON& = &H4 Private Const QS_MOUSEMOVE& = &H2 Private Const QS_PAINT& = &H20 Private Const QS_POSTMESSAGE& = &H8 Private Const QS_SENDMESSAGE& = &H40 Private Const QS_TIMER& = &H10 Private Const QS_MOUSE& = (QS_MOUSEMOVE _ Or QS_MOUSEBUTTON) Private Const QS_INPUT& = (QS_MOUSE _ Or QS_KEY) Private Const QS_ALLEVENTS& = (QS_INPUT _ Or QS_POSTMESSAGE _ Or QS_TIMER _ Or QS_PAINT _ Or QS_HOTKEY) Private Const QS_ALLINPUT& = (QS_SENDMESSAGE _ Or QS_PAINT _ Or QS_TIMER _ Or QS_POSTMESSAGE _ Or QS_MOUSEBUTTON _ Or QS_MOUSEMOVE _ Or QS_HOTKEY _ Or QS_KEY)Private Declare Function CreateWaitableTimer Lib "kernel32" _ Alias "CreateWaitableTimerA" ( _ ByVal lpSemaphoreAttributes As Long, _ ByVal bManualReset As Long, _ ByVal lpName As String) As LongPrivate Declare Function OpenWaitableTimer Lib "kernel32" _ Alias "OpenWaitableTimerA" ( _ ByVal dwDesiredAccess As Long, _ ByVal bInheritHandle As Long, _ ByVal lpName As String) As LongPrivate Declare Function SetWaitableTimer Lib "kernel32" ( _ ByVal hTimer As Long, _ lpDueTime As FILETIME, _ ByVal lPeriod As Long, _ ByVal pfnCompletionRoutine As Long, _ ByVal lpArgToCompletionRoutine As Long, _ ByVal fResume As Long) As LongPrivate Declare Function CancelWaitableTimer Lib "kernel32" ( _ ByVal hTimer As Long)Private Declare Function CloseHandle Lib "kernel32" ( _ ByVal hObject As Long) As LongPrivate Declare Function WaitForSingleObject Lib "kernel32" ( _ ByVal hHandle As Long, _ ByVal dwMilliseconds As Long) As LongPrivate Declare Function MsgWaitForMultipleObjects Lib "user32" ( _ ByVal nCount As Long, _ pHandles As Long, _ ByVal fWaitAll As Long, _ ByVal dwMilliseconds As Long, _ ByVal dwWakeMask As Long) As LongPrivate Declare Function GetLastError Lib "kernel32" () As Long 以上代码来自: SourceCode Explorer(源代码数据库) 复制时间: 2002-06-03 00:14:10 当前版本: 1.0.700 作者: Shawls 个人主页: Http://Shawls.Yeah.Net E-Mail: [email protected] QQ: 9181729
延时函数下'************************************************************************************Public hTimer As Long '定时器句柄 Public Sub Wait(lNumberOfSeconds As Long) Dim ft As FILETIME Dim lBusy As Long Dim lRet As Long Dim dblDelay As Double Dim dblDelayLow As Double Dim dblUnits As DoubleDim ErrCode As LongOn Error GoTo HELLhTimer = CreateWaitableTimer(0, True, App.EXEName & "Timer")If Err.LastDllError = ERROR_ALREADY_EXISTS ThenErrCode = GetLastError() If ErrCode <> 0 Then App.StartLogging "Modinitial.Wait 418 Sysrem Error, Code: " & ErrCode,vbLogEventTypeInformationErr.Clear End If ' If the timer already exists, it does not hurt to open it ' as long as the person who is trying to open it has the ' proper access rights. Else ft.dwLowDateTime = -1 ft.dwHighDateTime = -1 lRet = SetWaitableTimer(hTimer, ft, 0, 0, 0, 0) End If' Convert the Units to nanoseconds. dblUnits = CDbl(&H10000) * CDbl(&H10000) dblDelay = CDbl(lNumberOfSeconds) * 1000 * 10000' By setting the high/low time to a negative number, it tells ' the Wait (in SetWaitableTimer) to use an offset time as ' opposed to a hardcoded time. If it were positive, it would ' try to convert the value to GMT. ft.dwHighDateTime = -CLng(dblDelay / dblUnits) - 1 dblDelayLow = -dblUnits * (dblDelay / dblUnits - _ Fix(dblDelay / dblUnits))If dblDelayLow < CDbl(&H80000000) Then ' &H80000000 is MAX_LONG, so you are just making sure ' that you don't overflow when you try to stick it into ' the FILETIME structure. dblDelayLow = dblUnits + dblDelayLow End Ifft.dwLowDateTime = CLng(dblDelayLow) lRet = SetWaitableTimer(hTimer, ft, 0, 0, 0, False)Do ' QS_ALLINPUT means that MsgWaitForMultipleObjects will ' return every time the thread in which it is running gets ' a message. If you wanted to handle messages in here you could, ' but by calling Doevents you are letting DefWindowProc ' do its normal windows message handling---Like DDE, etc. lBusy = MsgWaitForMultipleObjects(1, hTimer, False, _ INFINITE, QS_ALLINPUT&) DoEvents Loop Until lBusy = WAIT_OBJECT_0' Close the handles when you are done with them. CloseHandle hTimerExit SubHELL:ErrCode = GetLastError() App.StartLogging "Modinitial.Wait 476 Sysrem Error, Code: " & ErrCode,vbLogEventTypeInformation Err.Clear Resume NextEnd Sub 以上代码来自: SourceCode Explorer(源代码数据库) 复制时间: 2002-06-03 00:14:25 当前版本: 1.0.700 作者: Shawls 个人主页: Http://Shawls.Yeah.Net E-Mail: [email protected] QQ: 9181729
定时器
Private Sub timPause_Timer()
bolPauseFlag = False
End Sub在函数中调用
timPause.interval=mmm,,你想要的延时时间
While bolPauseFlag
DoEvents
Wend
bolRowOrColFlag = True
Do Until Timer-OldT>1 '延时一秒
DoEvents
Loop
什么东西?是不是拼错了?
中怎么办,好象会影响下一个方块
如何利用Timer1.interval延迟时间?
非常麻烦
而且效果不好
sleep 1000
中实现的?
只是当判断方块落到最下一行和当前方块下有方块时,就停止
调用下一个方块,我只是想实现在判断前可以有一段时间来左右移动,
还有就是我在Timer中实现了每过一段时间就自动下落一行
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
有什么疑问 留言CSDN消息给我
http://www.csdn.net/Message_Board/Send.asp?sendto=sunxl
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
msgbox "!"
如果你是用Timer控制方块下落,左右键控制方块的移动.你根本不用给这个多余的时间,程序会因为不停的处理左右键而不触发(或减缓)Timer事件.这也就正好就符合了你的要求.
[email protected]
一定要给我来信,
记得写上您的来意,
附上您的E-mail地址,
和您的大名
见信即寄。
sleep 1000 (毫秒)
函数1
end if
而其他的如键盘,鼠标都不能响应!
FK1(0),FK1(1),FK1(2),FK1(3)分别为方块“坐标”,即图片框的Index
在游戏中每行10个图片框,共21行,(Image2控件数组)
比如第一行 1,2,3.....10
Image1为方块颜色
还有就是当方块停止不动时,图片框的tag为1,当tag为0时,可以移动
GOGO函数是调用下一个方块Private Sub Timer1_Timer()
' *************************** 方块自动下落 *******
If Counter = 1 Then ' *********** NO.1 长条 ***********
For i = 0 To 3
Image2(FK1(i)).Picture = Image1(0).Picture
Next i
For i = 0 To 3
FK1(i) = FK1(i) + 10
Next i
For i = 0 To 3
Image2(FK1(i)).Picture = Image1(1).Picture ' 向下移一行
Next i
If FK1(0) > 200 Or FK1(1) > 200 Or FK1(2) > 200 Or FK1(3) > 200 Then
Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1
GoGo
Exit Sub
End If
If Image2(FK1(0) + 10).Tag = 1 Or Image2(FK1(1) + 10).Tag = 1 Or Image2(FK1(2) + 10).Tag = 1 Or Image2(FK1(3) + 10).Tag = 1 Then
Image2(FK1(0)).Tag = 1 ' ***** 判断方块下方是否还有方块
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1
GoGo
Exit Sub
End If
End If
If Counter = 2 Then
......
end sub 谢谢~~~~~~~~~~
Private Sub Timer1_Timer() ' *************************** 方块自动下落 *******
If Counter = 1 Then ' *********** NO.1 长条 ***********
For i = 0 To 3
Image2(FK1(i)).Picture = Image1(0).Picture
Next i
If FK1(0) - 10 >= 0 And FK1(1) - 10 >= 0 And FK1(2) - 10 >= 0 And FK1(3) - 10 >= 0 Then
For i = 0 To 3
Image2(FK1(i) - 10).Picture = Image1(1).Picture ' 向下移一行
Next i
End If
If FK1(0) > 129 Or FK1(1) > 129 Or FK1(2) > 129 Or FK1(3) > 129 Then
PauseTime = 2 ' 设置暂停时间。
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1 GoGo
Exit Sub
End If
If Image2(FK1(0) + 10).Tag = "1" Or Image2(FK1(1) + 10).Tag = "1" Or Image2(FK1(2) + 10).Tag = "1" Or Image2(FK1(3) + 10).Tag = "1" Then
PauseTime = 2 ' 设置暂停时间。
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop
Image2(FK1(0)).Tag = 1 ' ***** 判断方块下方是否还有方块
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1
GoGo
Exit Sub
End If
For i = 0 To 3
FK1(i) = FK1(i) + 10
Next i
End If
If Counter = 2 Then
End If
End Sub
ElseIf FK1(0) > 200 Or FK1(1) > 200 Or FK1(2) > 200 Or FK1(3) > 200 Then
Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方 ******
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1
sndPlaySound "DOWN.WAV", &H1
GoGo
Exit Sub
End If
If Image2(FK1(0) + 10).Tag = 1 Or Image2(FK1(1) + 10).Tag = 1 Or Image2(FK1(2) + 10).Tag = 1 Or Image2(FK1(3) + 10).Tag = 1 Then
Image2(FK1(0)).Tag = 1 ' ******* 判断方块下方是否还有方块 ******
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1
sndPlaySound "DOWN.WAV", &H1
GoGo
Exit Sub
End If
End If
If FK1(0) > 200 Or FK1(1) > 200 Or FK1(2) > 200 Or FK1(3) > 200 Then
PauseTime = 15 ' 设置暂停时间。
Start1 = Timer
ooo = True
Do While Timer < Start1 + PauseTime
DoEvents
Loop
ooo = False
Image2(FK1(0)).Tag = 1 ' ******* 判断方块是否已到最下方 ******
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1
sndPlaySound "DOWN.WAV", &H1
GoGo
Exit Sub
End If
If Image2(FK1(0) + 10).Tag = 1 Or Image2(FK1(1) + 10).Tag = 1 Or Image2(FK1(2) + 10).Tag = 1 Or Image2(FK1(3) + 10).Tag = 1 Then
PauseTime = 15 ' 设置暂停时间。
Start1 = Timer
ooo = True
Do While Timer < Start1 + PauseTime
DoEvents
Loop
ooo = False
Image2(FK1(0)).Tag = 1 ' ******* 判断方块下方是否还有方块 ******
Image2(FK1(1)).Tag = 1
Image2(FK1(2)).Tag = 1
Image2(FK1(3)).Tag = 1
sndPlaySound "DOWN.WAV", &H1
GoGo
Exit Sub
End If
dwLowDateTime As Long
dwHighDateTime As Long
End TypePrivate Const WAIT_ABANDONED& = &H80&
Private Const WAIT_ABANDONED_0& = &H80&
Private Const WAIT_FAILED& = -1&
Private Const WAIT_IO_COMPLETION& = &HC0&
Private Const WAIT_OBJECT_0& = 0
Private Const WAIT_OBJECT_1& = 1
Private Const WAIT_TIMEOUT& = &H102&Private Const INFINITE = &HFFFF
Private Const ERROR_ALREADY_EXISTS = 183&Private Const QS_HOTKEY& = &H80
Private Const QS_KEY& = &H1
Private Const QS_MOUSEBUTTON& = &H4
Private Const QS_MOUSEMOVE& = &H2
Private Const QS_PAINT& = &H20
Private Const QS_POSTMESSAGE& = &H8
Private Const QS_SENDMESSAGE& = &H40
Private Const QS_TIMER& = &H10
Private Const QS_MOUSE& = (QS_MOUSEMOVE _
Or QS_MOUSEBUTTON)
Private Const QS_INPUT& = (QS_MOUSE _
Or QS_KEY)
Private Const QS_ALLEVENTS& = (QS_INPUT _
Or QS_POSTMESSAGE _
Or QS_TIMER _
Or QS_PAINT _
Or QS_HOTKEY)
Private Const QS_ALLINPUT& = (QS_SENDMESSAGE _
Or QS_PAINT _
Or QS_TIMER _
Or QS_POSTMESSAGE _
Or QS_MOUSEBUTTON _
Or QS_MOUSEMOVE _
Or QS_HOTKEY _
Or QS_KEY)Private Declare Function CreateWaitableTimer Lib "kernel32" _
Alias "CreateWaitableTimerA" ( _
ByVal lpSemaphoreAttributes As Long, _
ByVal bManualReset As Long, _
ByVal lpName As String) As LongPrivate Declare Function OpenWaitableTimer Lib "kernel32" _
Alias "OpenWaitableTimerA" ( _
ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal lpName As String) As LongPrivate Declare Function SetWaitableTimer Lib "kernel32" ( _
ByVal hTimer As Long, _
lpDueTime As FILETIME, _
ByVal lPeriod As Long, _
ByVal pfnCompletionRoutine As Long, _
ByVal lpArgToCompletionRoutine As Long, _
ByVal fResume As Long) As LongPrivate Declare Function CancelWaitableTimer Lib "kernel32" ( _
ByVal hTimer As Long)Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As LongPrivate Declare Function WaitForSingleObject Lib "kernel32" ( _
ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As LongPrivate Declare Function MsgWaitForMultipleObjects Lib "user32" ( _
ByVal nCount As Long, _
pHandles As Long, _
ByVal fWaitAll As Long, _
ByVal dwMilliseconds As Long, _
ByVal dwWakeMask As Long) As LongPrivate Declare Function GetLastError Lib "kernel32" () As Long
以上代码来自: SourceCode Explorer(源代码数据库)
复制时间: 2002-06-03 00:14:10
当前版本: 1.0.700
作者: Shawls
个人主页: Http://Shawls.Yeah.Net
E-Mail: [email protected]
QQ: 9181729
Public Sub Wait(lNumberOfSeconds As Long)
Dim ft As FILETIME
Dim lBusy As Long
Dim lRet As Long
Dim dblDelay As Double
Dim dblDelayLow As Double
Dim dblUnits As DoubleDim ErrCode As LongOn Error GoTo HELLhTimer = CreateWaitableTimer(0, True, App.EXEName & "Timer")If Err.LastDllError = ERROR_ALREADY_EXISTS ThenErrCode = GetLastError()
If ErrCode <> 0 Then
App.StartLogging "Modinitial.Wait 418 Sysrem Error, Code: " & ErrCode,vbLogEventTypeInformationErr.Clear
End If
' If the timer already exists, it does not hurt to open it
' as long as the person who is trying to open it has the
' proper access rights.
Else
ft.dwLowDateTime = -1
ft.dwHighDateTime = -1
lRet = SetWaitableTimer(hTimer, ft, 0, 0, 0, 0)
End If' Convert the Units to nanoseconds.
dblUnits = CDbl(&H10000) * CDbl(&H10000)
dblDelay = CDbl(lNumberOfSeconds) * 1000 * 10000' By setting the high/low time to a negative number, it tells
' the Wait (in SetWaitableTimer) to use an offset time as
' opposed to a hardcoded time. If it were positive, it would
' try to convert the value to GMT.
ft.dwHighDateTime = -CLng(dblDelay / dblUnits) - 1
dblDelayLow = -dblUnits * (dblDelay / dblUnits - _
Fix(dblDelay / dblUnits))If dblDelayLow < CDbl(&H80000000) Then
' &H80000000 is MAX_LONG, so you are just making sure
' that you don't overflow when you try to stick it into
' the FILETIME structure.
dblDelayLow = dblUnits + dblDelayLow
End Ifft.dwLowDateTime = CLng(dblDelayLow)
lRet = SetWaitableTimer(hTimer, ft, 0, 0, 0, False)Do
' QS_ALLINPUT means that MsgWaitForMultipleObjects will
' return every time the thread in which it is running gets
' a message. If you wanted to handle messages in here you could,
' but by calling Doevents you are letting DefWindowProc
' do its normal windows message handling---Like DDE, etc.
lBusy = MsgWaitForMultipleObjects(1, hTimer, False, _
INFINITE, QS_ALLINPUT&)
DoEvents
Loop Until lBusy = WAIT_OBJECT_0' Close the handles when you are done with them.
CloseHandle hTimerExit SubHELL:ErrCode = GetLastError()
App.StartLogging "Modinitial.Wait 476 Sysrem Error, Code: " & ErrCode,vbLogEventTypeInformation
Err.Clear
Resume NextEnd Sub
以上代码来自: SourceCode Explorer(源代码数据库)
复制时间: 2002-06-03 00:14:25
当前版本: 1.0.700
作者: Shawls
个人主页: Http://Shawls.Yeah.Net
E-Mail: [email protected]
QQ: 9181729