Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

honds

Alt-Tab and Ctrl-Esc

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am running my DirectDraw application in full screen using a while loop to do all the rendering. I was woundering how I can make it so I can use Alt-Tab or Ctrl-Esc to minimize the application and still be able to go back to it by Alt-Tabbing or clicking on the taskbar icon.

Share this post


Link to post
Share on other sites
Advertisement
You need to do something like this:


HRESULT hRet;
...
...
Ret = lpDDSfront->Flip(NULL, DDFLIP_WAIT);
if (Ret==DDERR_SURFACELOST)
{
lpDDSfront->Restore();
lpDDSback->Restore();
}


You also may want to reload all of you''re other surfaces as well (game sprites, tiles, etc.). You do this because when you Alt-Tab, Windows gets complete control again, and may accidentally dabble in you''re games memory, messing up you''re surfaces. So you have to Restore them. Hope that helps.




"We are the music makers, and we are the dreamers of the dreams."
- Willy Wonka

Share this post


Link to post
Share on other sites
Thank you for your reply though I just can''t get it working. Here is the exact code I use:


case WM_SETFOCUS:
SetCursor(0);
ACTIVE=TRUE;
if(FOCUSLOST){
Beacon(123);

hRet = g_pDDSPrimary->Flip(0, DDFLIP_WAIT);
if(hRet==DDERR_SURFACELOST){
g_pDDSPrimary->Restore();
g_pDDSBack->Restore();
Beacon(1234);
}
RestoreAll();
Beacon(11111);
ReacquireInput();

if(GameStatus==PLAY&&PlayStatus==PLAYING){
if(PAUSE)
Pause();
BLIT=TRUE;
Blitted=0;
}
FOCUSLOST=FALSE;
}
return 0;
case WM_KILLFOCUS:
ACTIVE=FALSE;

Beacon(321);
//ReleaseAll();
FOCUSLOST=TRUE;
ACTIVE=FALSE;
for(int Y=0;Y PlayDiks[Y]=ldiks[Y]=0;
if(GameStatus==PLAY&&PlayStatus==PLAYING&&!PAUSE){
Pause();
}

return 0;




It doesn''t work at all. This how RestoreAll() looks.


HRESULT
Game::RestoreAll(void)
{

Beacon(20000+GameStatus);

g_pDDSPrimary->Restore();

for(int i=0; i Beacon(10000+i);
hRet = (*GameSurfaces[GameStatus])->Restore();
if (hRet == DD_OK)
DDReLoadBitmap((*GameSurfaces[GameStatus][i]), (GameBitmaps[GameStatus][i]));
else
return hRet;
DDSetColorKey((*GameSurfaces[GameStatus][i]), RGB(0, 0, 0));
}

return DD_OK;
}


Can you see anything that is wrong with my code? I''d really like to get this working. When I switch back to my game the screen goes black.



Johan Torp - http://www.destruction.nu

Share this post


Link to post
Share on other sites
The annoying thing is that you have to reload the data to all of your video memory surfaces as well as restoring them, because GDI writes all over the video memory with cursors, icons and other junk. The system memory surfaces are safe, they just need to be restored. DDraw did not record what was in the surfaces (if it did, it would take up twice as much memory, and what would be the point in that?) and so you have to reload the stuff from the hard disk. If you alt-tab out of half-life you will notice that when you alt-tab back it waits a bit. This is it loading the textures back into video memory.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!