阅读:1882回复:10
SetTimer没有正常工作的问题求教
我在一个BUTTON控件中运行一段程序,用SetTimer计时,在OnTimer中向MFC的界面发送时间.但是现在设置的SetTimer没有正常的运行,而我把SetTimer放在别的BUTTON控件中都能正常工作.
|
|
沙发#
发布于:2005-01-16 11:25
你用单步调试,看看程序能否执行到定时器哪个语句?
|
|
板凳#
发布于: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 |
|
|
地板#
发布于:2005-01-16 14:04
不精确!!!!!!!!!!!!
|
|
地下室#
发布于:2005-01-17 10:46
我单步调试到SetTimer时, 弹出一个对话框说:
There is no source code available for the current location 为什么编译还能通过?而且在其他的控件里能正常运行呢? |
|
5楼#
发布于:2005-01-19 22:06
我单步调试到SetTimer时, 弹出一个对话框说: rebuild all看看 |
|
|
6楼#
发布于:2005-02-22 13:03
说得不清楚
|
|
7楼#
发布于:2005-02-28 15:42
CALLBACK应该用 stdcall吧?
记得不是特别清楚了,反正查查类型吧。 |
|
|
8楼#
发布于:2005-03-01 09:59
hwnd是什么,你是不是NULL
|
|
|
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. |
|
|
10楼#
发布于:2005-03-07 09:48
我这个是在一个读写硬盘程序的一个无限循环里面,是因为ON_TIME的消息级别是最低的,所以一直没有被处理,有什么办法能处理它?
|
|