Global timer and wndproc issues

Hi,
I have a global timer in my app that drives the opengl window created during runtime. I’m creating it using:

SetTimer(NULL, 0, 10, tick);

where tick is my TimerProc. In my app main loop, I have:

MSG msg;
while(GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}

This triggers a callback in tick as I expect. If I create an HWND and attach an opengl context to it, it still works fine. The issue is when I call SetWindowLongPtr to attach a userdata to the HWND. As soon as I call:

SetWindowLongPtr(hwnd, GWLP_USERDATA, udata);

the timer stops. Only after I close the window does the timer kick back in again. Obviously, the window is somehow taking over the WM_TIMER calls somehow, but I can’t quite find out why. The docs don’t mention anything about messages getting stolen by calling SetWindowLongPtr. Any ideas?

This sounds impossible. I’ve used such code, though with the old 32-bit versions: SetWindowLong(hwnd,GLW_USERDATA,udata); and it never misbehaved on me.
Try to write text time-stamps into a text-file from the timer-callback, to really see whether the timer stops.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.