关于MFC多媒体定时器问题,求帮助

aishudi9517 2017-09-07 03:50:58
开启了一个10ms的多媒体定时器,但是每过一段时间定时器就会超时好长时间

TIMECAPS tc;

if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
// Error; application can't continue.

wTimerRes = min(max(tc.wPeriodMin,TARGET_RESOLUTION), tc.wPeriodMax);
timeBeginPeriod(wTimerRes);

timeSetEventRslt = timeSetEvent(
10, // delay
wTimerRes, // resolution (global variable)
(LPTIMECALLBACK)TenMsecTimer, // callback function
wTimerRes/*reinterpret_cast<DWORD>(this)*/, // user data
TIME_PERIODIC/* | TIME_CALLBACK_FUNCTION | TIME_KILL_SYNCHRONOUS*/ ); // periodic call to callback func

if(timeSetEventRslt == NULL ) MessageBox(_T("TimeSetEvent fail. Maybe delay is not in the range of the minimum and maximum "));
...全文
382 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
不知道我的 2020-03-17
  • 打赏
  • 举报
回复
直接在窗口中添加Timer消息
aishudi9517 2017-09-11
  • 打赏
  • 举报
回复
那意思是不是说Windows无法使用高精度定时器(1ms)
赵4老师 2017-09-07
  • 打赏
  • 举报
回复
百度搜相关关键字。 提醒:Windows计时精度≈15ms
aishudi9517 2017-09-07
  • 打赏
  • 举报
回复
您说的是ON_WM_TIMER()的消息定时器吗,这个定时器时间不够精确
shinerise 2017-09-07
  • 打赏
  • 举报
回复
直接用一个timer的定时器周期控件能解决问题么?

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧