For reference, the code in VMK 3 looks like this:
Notice that I'm using PeekMessage with the PM_REMOVE flag. This means that we look to see if there is a message waiting for us, and if there is, then remove it from the queue and put it into m_Message to process.
In the code example from the book, PeekMessage is used with PM_NOREMOVE. This means that if there IS a message, it will be copied to msg, but it will still remain in the queue. GetMessage is then called to remove the message from the queue. If there is more than one message then you continue to loop inside the while-loop processing all the messages in the queue before exiting and going back into the for loop to render.
My implementation and the books implemenation is essentially the same thing. The only difference is that I have one looping structure (while) where as the book uses two (for and while).
Looking at the code that you implemented, I'm a little confused on how you intend it to work. From what I see, the program will:
* go into the for loop
* call RenderFrame once (!)
* go into the while loop
* continue looping inside the while loop until WM_QUIT is received or there is an error caused by GetMessage
Note that RenderFrame is only called once because after the first call you get stuck inside the while loop until you quit your game.
The other problem that I see in your implemenation is that RenderFrame is always called at least once, even if engine->QuitGame is true when you first get to the for-loop.
Hope this helps answer your question!