是API,如果你不Create Timer的话。单独Create Timer不知道是否可以,应该也可以。<br>一会俺试验一下。<br><br>{<br> The timeSetEvent function starts a specified timer event.<br> The multimedia timer runs in its own thread. After the event is activated,<br> it calls the specified callback function or sets or pulses the spe<br> cified event object.<br><br> MMRESULT timeSetEvent(<br> UINT uDelay,<br> UINT uResolution,<br> LPTIMECALLBACK lpTimeProc,<br> DWORD_PTR dwUser,<br> UINT fuEvent<br> );<br><br> uDelay:<br> Event delay, in milliseconds<br><br> uResolution:<br> Resolution of the timer event, in milliseconds.<br> A resolution of 0 indicates periodic events should occur with the<br> greatest possible accuracy.<br> You should use the use the maximum value appropriate to reduce system overhead.<br><br> fuEvent:<br> TIME_ONESHOT Event occurs once, after uDelay milliseconds.<br> TIME_PERIODIC Event occurs every uDelay milliseconds.<br>}<br>uses<br> MMSystem;<br><br>var<br> mmResult: Integer;<br><br>{回调函数}<br>procedure TimeCallBack(TimerID, Msg: Uint; dwUser, dw1, dw2: DWORD); pascal;<br>begin<br> // Do something here. This procedure will be executed each 10 ms<br> Form1.Label1.Caption := Form1.Label1.Caption + '%';<br>end;<br><br>// Set a new timer with a delay of 10 ms<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br> mmResult := TimeSetEvent(10, 0, @TimeCallBack, 0, TIME_PERIODIC);<br>end;<br><br>{退出的时候,取消事件}<br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> TimeKillEvent(mmResult);<br>end;