Most of the posters here advocate threads, but in simple cases like this, a message pump is easier and just about as effective. Add these lines to your loop

Code:
	MSG msg;
	while(PeekMessage(&msg, GetSafeHwnd(), 0, 0, PM_REMOVE))
		DispatchMessage(&msg);