随笔分类 -  Delphi-Timer

摘要:unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, mmsystem; type TForm1 = class 阅读全文
posted @ 2016-02-25 18:38 findumars 阅读(2045) 评论(0) 推荐(0) 编辑
摘要:明天去坐火车,回家,今天就没有事做,本来在弄一个跨进程获取其他程序里面组件,如ListView,ListBox,Button等的信息,突然有个想法自己写个Timer,不用SetTimer函数,我们自己用个多线程也正好实现这个.反正前段时间多线程也弄得比较多,本来想单独讲讲的,现在就用个例子来说明吧. 阅读全文
posted @ 2016-02-08 21:11 findumars 阅读(4223) 评论(0) 推荐(0) 编辑
摘要:在VC编程中,用SetTimer可以定义一个定时器,到时间了,就响应OnTimer消息,但这种定时器精度太低了。如果需要精度更高一些的定时器(精确到1ms),可以使用下面的高精度多媒体定时器进行代码优化,可以达到毫秒级的精度,而且使用方便。先要包含头文件"mmsystem.h"和库文件"winmm.... 阅读全文
posted @ 2015-12-17 18:34 findumars 阅读(4784) 评论(0) 推荐(0) 编辑
摘要:今天犯了一个粗心的错误,在无窗口线程中,SetTimer中设置计时器ID,而WM_TIMER消息响应函数中得到的计时器ID却不是之前设置的计时器ID.// 111902.cpp : Defines the entry point for the console application. // /... 阅读全文
posted @ 2015-09-29 21:17 findumars 阅读(2289) 评论(0) 推荐(0) 编辑
摘要:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;const TIMER_ID = 200;type TForm1 ... 阅读全文
posted @ 2015-08-21 17:05 findumars 阅读(1316) 评论(0) 推荐(0) 编辑
摘要:Windows下获取高精度时间注意事项 [转贴 AdamWu]花了很长时间才得到的经验,与大家分享。1.RDTSC-粒度:纳秒级不推荐优势:几乎是能够获得最细粒度的计数器抛弃理由:A)定义模糊-曾经据说是处理器的cyclecounter,但是后来似乎又不是了。有的机器上每秒的TSC增长值等于CPU频... 阅读全文
posted @ 2015-02-07 06:27 findumars 阅读(2755) 评论(0) 推荐(0) 编辑
摘要:SetTimer是设置定时器,每隔一段时间执行一个操作,原型如下 UINT_PTR SetTimer( HWND hWnd, // 窗口句柄 UINT_PTR nIDEvent, // 定时器ID,多个定时器时,可以通过该ID判断是哪个定时器 UINT uElapse, // 时间间隔,单位为毫秒 阅读全文
posted @ 2014-09-18 21:30 findumars 阅读(4589) 评论(2) 推荐(2) 编辑
摘要:procedure Timertodo(var messag:Tmessage);message WM_TIMER;procedure TForm1.FormCreate(Sender: TObject);beginsettimer(form1.Handle,1001,600,nil);end;pr... 阅读全文
posted @ 2014-09-10 16:28 findumars 阅读(616) 评论(0) 推荐(0) 编辑
摘要:http://social.msdn.microsoft.com/Forums/vstudio/en-US/c0f9bac9-d211-4b8b-ba99-f5a0ed0d2e0a/what-is-wm-id-code-0x0118?forum=vclanguage 编辑框出现输入光标时,产生的消息 阅读全文
posted @ 2014-08-11 18:00 findumars 阅读(1423) 评论(0) 推荐(0) 编辑
摘要:一,首先引入“mmsystem”单元。二,启动定时器: var MMTimerID: Integer; // 定时器ID MMTimerID := timeSetEvent(1000, 0, @TimerProc, 0, TIME_PERIODIC);三,定时器过程代码:procedure Tim... 阅读全文
posted @ 2014-07-29 19:26 findumars 阅读(413) 评论(0) 推荐(0) 编辑
摘要:TTimer = class(TComponent) private FInterval: Cardinal; FWindowHandle: HWND; FOnTimer: TNotifyEvent; FEnabled: Boolean; procedure Upd... 阅读全文
posted @ 2014-04-15 20:00 findumars 阅读(580) 评论(0) 推荐(0) 编辑