I wanted to try using SetTimer() as an FPS limiter but things aren't going so well.
Code:
#define FPS 60
#define IDT_TIMER 1001

const char oglclass[] = "OpenGL Renderer";

HWND window;
int w;
int h;

int WINAPI WinMain (HINSTANCE inst, HINSTANCE pinst, char* args, int show)
{

...

	window = CreateWindowEx(WS_EX_CLIENTEDGE, oglclass, "OpenGL", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
	                        CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, inst, NULL);
	if (window == NULL || SetTimer(window, IDT_TIMER, (2000 + FPS)/(2*FPS), NULL) == 0) {
		ErrorMsg();
		return 1;
	}
	ShowWindow(window, show);
	UpdateWindow(window);

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

	return msg.wParam;
}
WM_TIMER should be sent every 17 milliseconds to oglproc but it seems like it doesn't.
oglproc looks kinda like
Code:
LRESULT CALLBACK oglproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
	static HDC   hdc;
	static HGLRC hrc;
	static RECT  re = {0, 0, 0, 0};

	switch (msg) {

...

		case WM_SIZE:
			re.right  = w = LOWORD(lparam);
			re.bottom = h = HIWORD(lparam);
			if (!h)
				h = 1;
			glViewport(0, 0, w, h);
		case WM_PAINT:
			render();
			SwapBuffers(hdc);
			break;
		case WM_TIMER:
			next_frame();
			render();
			SwapBuffers(hdc);
			break;
		default:
			return DefWindowProc(hwnd, msg, wparam, lparam);
			break;
	}

	return 1;
WM_TIMER is never recieved, not even manually with PostMessage (I have yet to try SendMessage()). MSDN mentions that WM_TIMER is low priority but how low can it be?
It did get sent at one time, when case WM_TIMER: was below case WM_SIZE: and I didn't notice that it 'spilled' over to WM_TIMER, however debug messages indicated that wparam was the same as IDT_TIMER so WM_TIMER was called as well but strangely enough it was only sent when the window was minimized. I can't seem to reproduce it though but so far it seems to only want to get sent when it's tickled in the right spot.

I think it might've happened when I had a TimerProc in use while also catching WM_TIMER messages but I don't see why, as I understood the documentation WM_TIMER will be sent to a TimerProc if there's one attatched, otherwise it's sent to your window procedure?
Quote Originally Posted by MSDN
If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue.
Quote Originally Posted by 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.