Code: Select all
FUNCTION WndProc(ByVal hWnd AS HWND, BYVAL uMsg AS UINT, BYVAL wParam AS WPARAM, BYVAL lParam AS LPARAM) AS LRESULT
Static timerID0 As UINT_PTR
Static timerID1 As UINT_PTR
Select Case uMsg
Case WM_CREATE
timerID0 = SetTimer( hWnd, 1, 2000, NULL )
timerID1 = SetTimer( Null, 0, 4000, Cast(TIMERPROC, @MyFunc) ) ' The Cast is not required
Print timerID0, timerID1
Exit Function
Case WM_TIMER
If wParam = timerID0 Then ' Not needed as only one hWnd timer
Print "timerID0 2 seconds"
End IF
blah, blah
Just before WndProc I added
Code: Select all
Function MyFunc(ByVal hWnd As HWND, BYVAL uMsg AS UINT, ByVal idEvent AS Uint_Ptr, ByVal dwTime AS DWORD) As LRESULT
Print "timerID1 4 seconds"
Function = DefWindowProcW(hwnd, uMsg, idEvent, dwTime)
End Function
On execution I got:
Code: Select all
1 12001
timerID0 2 seconds
timerID1 4 seconds
timerID0 2 seconds
timerID0 2 seconds
timerID1 4 seconds
timerID0 2 seconds
timerID0 2 seconds
timerID1 4 seconds
timerID0 2 seconds
timerID0 2 seconds
timerID1 4 seconds
timerID0 2 seconds
timerID0 2 seconds
timerID1 4 seconds
timerID0 2 seconds
timerID0 2 seconds
timerID1 4 seconds
timerID0 2 seconds
and so on until I hit the Close button.
The timers were killed in WM_DESTROY before PostQuitMessage(0).
Code: Select all
KillTimer hWnd, timerID0
KillTimer Null, timerID1
I should add that I bashed my head against a brick wall quite a few times before the above worked.