# Task switching (Alt-Tab for instance) out of a DirectX Program Problem

This topic is 4855 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

##### Share on other sites
Have you tried, pausing it than alt-tabing out of it?

##### Share on other sites
My "Pause" just skips the update() function, if you get what I mean. I don't think that will help much.

##### Share on other sites
Bump for the afternoon/evening crew.

##### Share on other sites
It almosts looks like your program is not handling system messages correctly. Things such as redrawing the window or gaining focus are not being processed. Do you have a function which eats all those messages and is it being called every frame?

void HandleSystemMessages(){  MSG     msg;  BOOL bGot = FALSE;  while(1)  {    bGot = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE);    if (bGot == TRUE)    {      // DISPATCH (call the win proc to handle messages)      TranslateMessage(&msg);      DispatchMessage(&msg);    }    else    {      break;    }  }  return;}

##### Share on other sites
Ah. Yes, your hunches are correct.

My original game loop was a mere while loop involving update(), handleInput(), render(), and stuff to calculate the time it took to do all that, for timing purposes. I recall when I did use Peek/Translate/DispatchMessage, and I certainly know of them, I did not know their purposes were for things like that. I also seem to recall the DirectX book I used to learn from stating that I could get rid of them, but it didn't. It just said replace GetMessage with the superior PeekMessage. That was why I didn't have them in there.

And here I thought it would be a complicated problem. Seems like all the bugs I've had in fixing this thing have been fairly simple, which I guess is like how most things are.

I was almost about to post that this wasn't helping, until I realized where my program was freezing. I dont think this little loop in handleInput() was being very nice in letting my function return so I can handle a switching in message or whatever:

while( true ){     hResult = inputDevice->GetDeviceState( sizeof( keyBuffer ), ( LPVOID )&keyBuffer );     if( hResult == DIERR_INPUTLOST || hResult == DIERR_NOTACQUIRED )          inputDevice->Acquire();     else          break;}

Thanks for the help.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 23
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
634779
• Total Posts
3019240
×