windchen
驱动牛犊
驱动牛犊
  • 注册日期2004-08-11
  • 最后登录2010-01-14
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望11点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1842回复:10

SetTimer没有正常工作的问题求教

楼主#
更多 发布于:2005-01-16 11:14
我在一个BUTTON控件中运行一段程序,用SetTimer计时,在OnTimer中向MFC的界面发送时间.但是现在设置的SetTimer没有正常的运行,而我把SetTimer放在别的BUTTON控件中都能正常工作.
Gong_XG
驱动太牛
驱动太牛
  • 注册日期2002-10-01
  • 最后登录2010-11-25
  • 粉丝0
  • 关注0
  • 积分313分
  • 威望46点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2005-01-16 11:25
你用单步调试,看看程序能否执行到定时器哪个语句?
liwashington
驱动小牛
驱动小牛
  • 注册日期2004-04-30
  • 最后登录2010-10-21
  • 粉丝0
  • 关注0
  • 积分-11分
  • 威望98点
  • 贡献值1点
  • 好评度12点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2005-01-16 12:47
不知道你具体的实现怎么样,不过如果是回调函数方式的话,好像要在SetTimer的线程中处理消息。MSDN:
When you specify a TimerProc callback function, the default window procedure calls the callback function when it processes WM_TIMER. Therefore, you need to dispatch messages in the calling thread, even when you use TimerProc instead of processing WM_TIMER
我只想有个好老婆,每天有几顿好饭吃……
Gong_XG
驱动太牛
驱动太牛
  • 注册日期2002-10-01
  • 最后登录2010-11-25
  • 粉丝0
  • 关注0
  • 积分313分
  • 威望46点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
地板#
发布于:2005-01-16 14:04
不精确!!!!!!!!!!!!
windchen
驱动牛犊
驱动牛犊
  • 注册日期2004-08-11
  • 最后登录2010-01-14
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望11点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2005-01-17 10:46
我单步调试到SetTimer时, 弹出一个对话框说:
  There is no source code available for the current location

为什么编译还能通过?而且在其他的控件里能正常运行呢?
AllenZh
驱动老牛
驱动老牛
  • 注册日期2001-08-19
  • 最后登录2015-11-27
  • 粉丝19
  • 关注10
  • 积分1316分
  • 威望2387点
  • 贡献值7点
  • 好评度321点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2005-01-19 22:06
我单步调试到SetTimer时, 弹出一个对话框说:
  There is no source code available for the current location

为什么编译还能通过?而且在其他的控件里能正常运行呢?

rebuild all看看
1,承接Windows下驱动/应用开发 2,本人原创虚拟鼠标/键盘,触摸屏,虚拟显卡,Mirror驱动,XP无盘的SCSI虚拟磁盘驱动等 3,windows下有尝技术服务(包括BUG调试,员工培训等) 欢迎深圳和海外企业联系.msn:mfczmh@sina.com
minardi
驱动牛犊
驱动牛犊
  • 注册日期2004-09-24
  • 最后登录2005-02-22
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2005-02-22 13:03
说得不清楚
zmwk
驱动中牛
驱动中牛
  • 注册日期2001-05-15
  • 最后登录2009-04-05
  • 粉丝0
  • 关注0
  • 积分59分
  • 威望51点
  • 贡献值0点
  • 好评度2点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2005-02-28 15:42
CALLBACK应该用 stdcall吧?
记得不是特别清楚了,反正查查类型吧。
A strong man can save himself. A great man can save another.
walkonthesky
驱动中牛
驱动中牛
  • 注册日期2003-11-26
  • 最后登录2012-11-06
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
8楼#
发布于:2005-03-01 09:59
hwnd是什么,你是不是NULL
[img]http://www.driverdevelop.com/forum/upload/walkonthesky/2004-07-08_2004-07-07_b847.gif[/img]
walkonthesky
驱动中牛
驱动中牛
  • 注册日期2003-11-26
  • 最后登录2012-11-06
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望20点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2005-03-01 10:06
UINT_PTR SetTimer(          HWND hWnd,
    UINT_PTR nIDEvent,
    UINT uElapse,
    TIMERPROC lpTimerFunc
);
Parameters

hWnd
[in] Handle to the window to be associated with the timer. This window must be owned by the calling thread. If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
nIDEvent
[in] Specifies a nonzero timer identifier. If the hWnd parameter is NULL, this parameter is ignored. If the hWnd parameter is not NULL and the window specified by hWnd already has a timer with the value nIDEvent, then the existing timer is replaced by the new timer. When SetTimer replaces a timer, the timer is reset. Therefore, a message will be sent after the current time-out value elapses, but the previously set time-out value is ignored.
uElapse
[in] Specifies the time-out value, in milliseconds.
Windows NT/2000/XP: If uElapse is greater than USER_TIMER_MAXIMUM, the timeout is set to 1.

Windows 2000/XP: If uElapse is less than USER_TIMER_MINIMUM, the timeout is set to USER_TIMER_MINIMUM.

Windows Server 2003: If uElapse is greater than USER_TIMER_MAXIMUM, the timeout is set to USER_TIMER_MAXIMUM.

Windows XP SP2/Windows Server 2003 SP1: If uElapse is less than USER_TIMER_MINIMUM, the timeout is set to USER_TIMER_MINIMUM. If uElapse is greater than USER_TIMER_MAXIMUM, the timeout is set to USER_TIMER_MAXIMUM.

lpTimerFunc
[in] Pointer to the function to be notified when the time-out value elapses. For more information about the function, see TimerProc. If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue. The hwnd member of the message\'s MSG structure contains the value of the hWnd parameter.
Return Value

If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. An application can pass this value to the KillTimer function to destroy the timer.

If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.

If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.


[img]http://www.driverdevelop.com/forum/upload/walkonthesky/2004-07-08_2004-07-07_b847.gif[/img]
windchen
驱动牛犊
驱动牛犊
  • 注册日期2004-08-11
  • 最后登录2010-01-14
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望11点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
10楼#
发布于:2005-03-07 09:48
我这个是在一个读写硬盘程序的一个无限循环里面,是因为ON_TIME的消息级别是最低的,所以一直没有被处理,有什么办法能处理它?
游客

返回顶部