program timer ;uses windows,messages,sysutils;
var
v_timer:integer;
i:integer;
dc:Hwnd;
msg:Tmsg;
Handle,handle2:WORD;procedure TimerProc(hwnd:HWND;uMsg,idEvent:UINT;dwTime:DWORD); stdcall; //此过程就是没有被执行过
begin
dc:=getdc(0);
TextOut(dc,10,10,pchar(inttostr(i)),length(inttostr(i)));
messagebox(0,pchar(inttostr(i)),pchar(inttostr(i)),mb_ok);
i:=i+1;
end;
begin
Handle2 :=GetCurrentThreadID;
messagebox(0,'ok',pchar('the Handle is '+inttostr(Handle2)),0);
v_timer:=5000;
SetTimer(0,10,5000,@TimerProc);while(getmessage(msg,0,0,0)) do
begin
case msg.message of
wm_quit:exit;
wm_close:exit;
wm_timer:begin
messagebox(0,PCHAR(inttostr(msg.wParam)+'AND'+inttostr(msg.lParam)),'a',mb_ok);
end;
end;
end;end./////////////////wm_timer消息有响应,可就是过程没有自动被调用,谁知道是怎么回是,在消息里如何判断出定时器ID以确定是哪个定时器发出的消息
var
v_timer:integer;
i:integer;
dc:Hwnd;
msg:Tmsg;
Handle,handle2:WORD;procedure TimerProc(hwnd:HWND;uMsg,idEvent:UINT;dwTime:DWORD); stdcall; //此过程就是没有被执行过
begin
dc:=getdc(0);
TextOut(dc,10,10,pchar(inttostr(i)),length(inttostr(i)));
messagebox(0,pchar(inttostr(i)),pchar(inttostr(i)),mb_ok);
i:=i+1;
end;
begin
Handle2 :=GetCurrentThreadID;
messagebox(0,'ok',pchar('the Handle is '+inttostr(Handle2)),0);
v_timer:=5000;
SetTimer(0,10,5000,@TimerProc);while(getmessage(msg,0,0,0)) do
begin
case msg.message of
wm_quit:exit;
wm_close:exit;
wm_timer:begin
messagebox(0,PCHAR(inttostr(msg.wParam)+'AND'+inttostr(msg.lParam)),'a',mb_ok);
end;
end;
end;end./////////////////wm_timer消息有响应,可就是过程没有自动被调用,谁知道是怎么回是,在消息里如何判断出定时器ID以确定是哪个定时器发出的消息
解决方案 »
- 閏于winsock控件用getdata返回亂碼的問題
- 问一个弱弱的问题:DCU是什么类型的文件?
- 菜鸟求救~!Rave报表中做主从报表.....
- 现在那个程序界面控件组比较好用!!!
- FastReport的一个简单问题!在线等
- 200分高分求解翻译以下VBA代码
- 想做一个车辆定位系统有设备,想问一下有无此方面经验的兄弟关于通迅连com口要那方面的知识.
- 有关DELPHI应用程序“换肤”和“INI文件的加密解密”的问题,大家进来看看。。。。。。
- 数据库问题 急!!!
- 怎样去掉 DBGRID 中的 LOOKUP 字段的下拉列表?
- 怎么读出ie的历史纪录阿
- 求直接打印memo1中的内容的简单打印方法
program timer ;uses windows,messages,sysutils;
var
v_timer:integer;
i:integer;
dc:Hwnd;
msg:Tmsg;
Handle,handle2:WORD;procedure TimerProc(hwnd:HWND;uMsg,idEvent:UINT;dwTime:DWORD); stdcall; //此过程就是没有被执行过
begin
dc:=getdc(0);
TextOut(dc,10,10,pchar(inttostr(i)),length(inttostr(i)));
messagebox(0,pchar(inttostr(i)),pchar(inttostr(i)),mb_ok);
i:=i+1;
end;
begin
Handle2 :=GetCurrentThreadID;
messagebox(0,'ok',pchar('the Handle is '+inttostr(Handle2)),0);
v_timer:=5000;
SetTimer(0,10,5000,@TimerProc);while(getmessage(msg,0,0,0)) do
begin
case msg.message of
wm_quit:exit;
wm_close:exit;
wm_timer:begin
messagebox(0,PCHAR(inttostr(msg.wParam)+'AND'+inttostr(msg.lParam)),'a',mb_ok);
end;
end; dispatchmessage(msg); //这里end;end.另外,SetTimer(0,10,5000,@TimerProc);这个10没用,应该为NULL,看一下SetTimer的HELP可知
还有,SetTimer返回值就是Timer的id,可用它来判是那个Timer发的消息:
WM_TIMER的wParam就是这个id,也就是TimerProc中的idEvent
program timer ;uses
windows,
messages,
sysutils,
MyTimer in 'MyTimer.pas';var
v_timer:integer;
i:longint;
dc:Hwnd;
msg:Tmsg;
Handle,handle2:WORD;
SubThreadID:Thandle;procedure TimerProc(hwnd:HWND;uMsg,idEvent:UINT;dwTime:DWORD); stdcall;
begin
v_timer:=5000;
while (true) do
begin
sleep(v_timer);
PostThreadMessage(Handle2,wm_user+wm_timer,0,0);
end;
end;
begin
i:=0;
Handle2 :=GetCurrentThreadID;
messagebox(0,'ok',pchar('the Handle is '+inttostr(Handle2)),0);
//SetTimer(0,10,5000,@TimerProc);
CreateThread(nil,0,@TimerProc,nil,0,SubThreadID);
dc:=getdc(0);
while(getmessage(msg,0,0,0)) do
begin
case msg.message of
wm_quit:exit;
wm_close:exit;
wm_timer:begin
messagebox(0,PCHAR(inttostr(msg.wParam)+'AND'+inttostr(msg.lParam)),'a',mb_ok);
end;
wm_user+wm_timer:begin TextOut(dc,10,10,pchar(inttostr(i)),length(inttostr(i)));
i:=i+1; end;
end;
end;
CloseHandle(dc);
end.
1.QueryPerformanceCounter
2. RDTSC(CPU指令数)
3.直接对8255芯片进行编程