`

VB 中运用 TimeSetEvent 代替 Timer 控件

    博客分类:
  • vb
VB 
阅读更多

窗体代码:

Option Explicit
Private Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As Long
Private Declare Function
timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
Dim
p As Long
Private Const
TIME_周期 As Long = 1
Private Const TIME_一次性 As Long = 0

Private Sub Form_DblClick()
timeKillEvent p
p =
0
End Sub

Private Sub
Form_Load()
p = timeSetEvent(
300000, 10, AddressOf TimeProc, 1, TIME_一次性)
Debug.Print timeGetTime
End Sub

Private Sub
Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If p Then timeKillEvent p: p = 0: Cancel = True: Timer1.Enabled = True
End Sub

Private Sub
Timer1_Timer()
Timer1.Enabled =
False
Unload Me
End Sub
[/font]



模块代码:

Option Explicit
Public Declare Function timeGetTime Lib "winmm.dll" () As Long

Sub
TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
Debug.Print timeGetTime
End Sub

 

分享到:
评论

相关推荐

    TimeSetEvent代替Timer控件

    这是我用VB写的用 TimeSetEvent函数代替Timer控件的代码, 它可以实现更细微更精确的计时。 如果你的程序有这样的要求,可以参考一下哦。

    VB6精确timeSetEvent定时

    VB6的定时器控件定时精度不高,要求高精度定时的场合,可以考虑使用timeSetEvent函数,同时,由于VB6对多线程得支持不好,可以考虑在VB5下编译,VB5得多线程支持好,定时函数需要一个附加线程。

    office VBA 用api做的计时器timer

    可以用在无窗体的模块中,本timer类模块,完全模拟vb自带控件,事件,属性完全与vb自带的timer控件相同,例如:mTimer.Interval = 500设置计时器时间,mTimer.Enabled = True启动计时器,mTimer.Enabled = False关闭...

    TimeSetEvent VB多线程例程

    VB TimeSetEvent 多线程 例程

    VB的TimeSetEvent例子

    VB的TimeSetEvent API多线程的例程

    在VC编程中使用timeSetEvent

    在VC编程中,用SetTimer可以定义一个定时器,到时间了,就响应OnTimer消息,但这种定时器精度太低了。如果需要精度更高一些的定时器(精确到1ms),可以使用下面的高精度多媒体定时器进行代码优化,可以达到毫秒级的...

    VB不用Timer播放动画

    用timeSetEvent延时 精确度为ms 实际上实现了多线程 使用GDI+绘制png图片

    VC程序多媒体定时_timeSetEvent

    VC程序多媒体定时_timeSetEvent

    timesetevent和QueryPerformanceFrequency定时器

    timesetevent和QueryPerformanceFrequency 作为定时器的比较,实现了这2个函数的定时功能,并显示各自的定时时间

    vc高精度定时器timeSetEvent

    本实例可在VC或EVC运行通过,主要解决同WM_TIME定时器误差太大的问题,本例程的定时器精度1 ms....

    c# time 精确Timer

    c# 精确定时器,精确Time 比System.Threading.Timer、System.Windows.Forms.Timer、System.Timers.Timer精准

    易语言两款创建时钟API

    易语言两款创建时钟API源码,两款创建时钟API,TimerProc,timeKillEvent,timeSetEvent,设置时钟_,销毁时钟_

    BCB 6 調用 1ms timer 例

    BCB6 1亳秒 Timer 應用例,源代碼 下例函數應用例 QueryPerformanceCounter QueryPerformanceFrequency timeKillEvent timeEndPeriod timeGetDevCaps timeBeginPeriod timeSetEvent

    zwc自定义定时器Timer

    1.MFC中的SetTimer有二个缺点:最多只能定时24天(0x7FFFFFFF毫秒)、是基于消息的 2.timeSetEvent有一个缺点:最多只能定时16分钟(1000000毫秒),而且时间定的长了不一定会调用回调函数 经研究,文中包含的定时器...

    VS2015多媒体1ms定时器和dock控件布局使用

    VS2015多媒体1ms定时器和dock控件布局使用

    VS2010多媒体1ms定时器和dock控件布局使用

    VB.NET c#.net的例程都有VB.NET c#.net的例程都有

    VC记时函数测试

    测试了几个记时函数,GetTickCount;timeSetEvent等,留在网上以备自己在外面的时候使用。

    多媒体定时器应用

    多媒体定时器与VC自带Timer比较 void CLxDlg::OnMulticlk() { // TODO: Add your control notification handler code here TimerID=timeSetEvent(50,1,(LPTIMECALLBACK)TimeProc,(DWORD)this,TIME_PERIODIC); ...

    MMTimer.zip

    多媒体定时器不需要消息环,内部自己创建线程。精度比WM_TIMER更高。CMMTimer是对多媒体定时器timeSetEvent 的封装,方便我们快速使用定时器。

    vc6.0中c语言控制台程序中的定时技术(定时器)

    打开main.c编译运行,注意,打开main.c之后一定要将win32timer.c也加进工程中一起编译,下面有图。在开发单片机、ARM以及Linux系统的程序时,因为硬件定时中断的存在我们很方便构造出定时ISR,然而在VC6.0中,我们...

Global site tag (gtag.js) - Google Analytics