I am now in trouble.
In Function WndProc, among other declarations, 'Static timerID As UINT_PTR' is used.
In WndPrc we have:
Code: Select all
Select Case uMsg
Case WM_CREATE
timerID = SetTimer( Null, 0, 2000, Null )
Print timerID
Case WM_TIMER
Print "In WM_TIMER"
I am getting a different timerID each time the code is run, but a WM_TIMER message is not being sent. That is I am not getting "In WM_TIMER". The return value is nonzero and therefore successful – but clearly is not.
However, if we use 'timerID = SetTimer( hWnd, 1, 2000, Null )' then that works; timerID = 1.
Microsoft specifically writes, "If the call is not intended to replace an existing timer, nIDEvent should be 0 if the hWnd is NULL."
The SetTimer docs are badly written.
"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."
In other words, the return value is nIDEvent. Why refer to it as 'a nonzero integer' when it is nIDEvent?
Not only badly written but, it seems to me, we cannot create a 'global timer'.
So keep well away from using hWnd as Null. If we only create one timer, we don't need to check wParam. We do if we use more than one timer as in:
Code: Select all
SetTimer ( hWnd, 1, 100, Null )
SetTimer( hWnd, 2, 1000, Null )
We now need to test wParam in WM_TIMER.
What a shambles, Microsoft.