From: AliR on 28 Feb 2005 10:54
"Rick" <rick(a)cortex.com> wrote in message
> Thanks again,
> Following you previous answer, I looked again in the MSDN help and saw
> the SetTimer version with the 3 parameters (I think that it belongs to the
> CWnd class) - the one that I use, returns the ID number that should be
> with KillTimer. As I checked in the debugger it was usually similar to the
> first argument given to SetTimer
What do you mean by usually similar? Unless there is an error in your case
they should be identical!
I think microsoft has mess up the documentation, between the SDK and the MFC
Anyway, other then when there is an error, the only time I know that
SetTimer returns something different than the timer id is when you are using
the SDK ::SetTimer and add you pass a NULL as the hwnd, in which case you
are assigning a callback function to the timer (instead of the WM_TIMER
message) in which case SetTimer will return the ID that it has assinged to
the timer for you.
From: Bob Moore on 28 Feb 2005 16:59
On Mon, 28 Feb 2005 09:03:29 +0200, Rick wrote:
>I use extensively the timers in my View mfc application but I find the
>documentation is not absolutely clear. I use the version with 3 paramteres -
>the last one is NULL which indicates using the View OnTimer routine. In the
>documentation it says to use KillTimer with the first parameter being used
>in the SetTimer function and in some other palce to use it with the return
>value of SetTimer.
IIRC, this is a historical hangover from the Win16 days when timers
were a scarce system resource. You had (if memory serves) something
like 16 timers in Windows 3.0, and 32 in Windows 3.1. Hence the
chances were that any given call to SetTimer might well fail, and it
was very important to test the value returned by the API.
Ever since the change to Win32, timers have been (effectively)
unlimited, and I have for as long as I can recall simply done
#define MY_TIMER 1
SetTimer (MY_TIMER, 1000, NULL);
Strictly speaking, I guess you should test the return value from
SetTimer : but in the bright sunny uplands of Win32 world, it will
pretty much always be the same as the ID you specified.
You know what ? ironically, I can't check the old docs to verify this,
because I'm in thje middle of setting up a new PC and haven't
installed my Win32 compiler* and MSDN.... the PC is a new AMD 64 bit
* VC6, natch.
(this is a non-commercial site and does not accept advertising)
Do not reply via email unless specifically requested to do so.
Unsolicited email is NOT welcome and will go unanswered.