Simple question about while (GetMessage (&messages, NULL, 0, 0)) loop

I've been making a server program and inside the loop I have the server respond to messages from clients.
I've noticed that if the window is in focus it always answers instantaneously, but if the window is not in focus, it does not respond to the clients until it gains focus.
It would seem to me then, that background windows don't process messages until they get focus. Is this correct?
How can I avoid the issue so that my server responds immediately?
Last edited on
Have you looked at PeekMessage(); ?
I'd never looked at it before, thanks ^.^

My main loop now looks something like this:
while(running)
{
if (PeekMessage( &messages, NULL, 0, 0, PM_REMOVE)!= 0)
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
packet = server->Receive();
if(packet != NULL)
{
HandlePacket(server, packet);
server->DeallocatePacket(packet);
}
for(int i = 0; i < PlayerList.size(); i++)
if(!server->IsActivePlayerID(PlayerList.at(i).ID))
PlayerList.erase(PlayerList.begin()+i);
}

Now I'd like to know if its bad practice to have a bool variable determining the loop of a windows program.
I have WM_CLOSE and WM_DESTROY change the value to false, is there any other condition where Windows would send a message to my program to quit and end up leaving it running still?
Last edited on
WM_QUIT? Have a look up to see what the PostQuitMessage() creates.

Thanks, Zaita ^.^ you're always so helpful
I have a OpenGL 3D engine @ home that I wrote. :P So I've been through all this stuff myself.
learn
Topic archived. No new replies allowed.