You need a GetMessage
loop from that article instead.
Well, that doesn't make any sense of course. If the fDone flag is set to TRUE, there's no way it can stay inside the loop and keep calling PeekMessage(). Nor can PeekMessage() block. Blowing the stack frame could have an effect like that, but that's not indicated here and always an explanation of last resort.
The more likely explanation is that this code gets repeatedly executed from the top. Maybe by you calling it from the window procedure. Yes, that can get you in an endless loop easily if you don't call DispatchMessage(). The WM_PAINT message is an obvious candidate, it will just keep firing without letup if you don't call Begin/EndPaint(). This is just a theory of course, can't know for sure without knowing how this code is getting called.