怎么实现真正的Idle()函数?我写了一个,在C++Builder下好用,但是Delphi下面就不起作用. ( 积分: 40 )

  • 主题发起人 主题发起人 freeia
  • 开始时间 开始时间
F

freeia

Unregistered / Unconfirmed
GUEST, unregistred user!
void idle( &nbsp;DWORD dwTimeout,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD dwTimeInterval = 1)<br>{<br> &nbsp; &nbsp;MSG msg;<br> &nbsp; &nbsp;DWORD dwTimeNext = GetTickCount() + dwTimeout;<br> &nbsp; &nbsp;// Wait time next.<br> &nbsp; &nbsp;while (GetTickCount() &lt; dwTimeNext)<br> &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp;Sleep(dwTimeInterval);<br> &nbsp; &nbsp; &nbsp; &nbsp;if (PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))<br> &nbsp; &nbsp; &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TranslateMessage(&amp;msg);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DispatchMessage(&amp;msg);<br> &nbsp; &nbsp; &nbsp; &nbsp;}<br> &nbsp; &nbsp;}<br>}<br><br><br>在Delphi下面有对应的吗?<br>Sleep()API是不行的,会堵塞其它的消息处理.
 
void idle( &nbsp;DWORD dwTimeout,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DWORD dwTimeInterval = 1)<br>{<br> &nbsp; &nbsp;MSG msg;<br> &nbsp; &nbsp;DWORD dwTimeNext = GetTickCount() + dwTimeout;<br> &nbsp; &nbsp;// Wait time next.<br> &nbsp; &nbsp;while (GetTickCount() &lt; dwTimeNext)<br> &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp;Sleep(dwTimeInterval);<br> &nbsp; &nbsp; &nbsp; &nbsp;if (PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))<br> &nbsp; &nbsp; &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;TranslateMessage(&amp;msg);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DispatchMessage(&amp;msg);<br> &nbsp; &nbsp; &nbsp; &nbsp;}<br> &nbsp; &nbsp;}<br>}<br><br><br>在Delphi下面有对应的吗?<br>Sleep()API是不行的,会堵塞其它的消息处理.
 
后退
顶部