Jump to content
  • Advertisement
Sign in to follow this  
AngleWyrm

Handling Alt-Tab in fullscreen app

This topic is 4090 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 spent rather a lot of time searching for the answer to this question, and eventually had to generate my own blend of solution. It works, so this is how I did it:
void win_app::render_scene(float elapsed_seconds)
{
    if(dx.screen == NULL){
        return;
    }

    static HRESULT result;
    result = dx.screen->TestCooperativeLevel();
    switch(result){
        case D3D_OK:
            break;
        case D3DERR_DEVICELOST:
            return;
        case D3DERR_DEVICENOTRESET:
            dx.reset(main_window);
            return;
        case D3DERR_DRIVERINTERNALERROR:
            return;
    }
    // render code 
The dx.screen object is a LPDIRECT3DDEVICE9. Code in the dx.reset(HWND)
void d3d_class::reset(HWND window)
{
     screen->Reset(&screen_parameters);
};



Any comments? Anything I'm missing? [Edited by - AngleWyrm on June 8, 2007 2:53:03 PM]

Share this post


Link to post
Share on other sites
Advertisement
You might like to use CheckCooperativeLevel() instead rather than causing an exception by using TestCooperativeLevel(). Checking it instead gives a result code you can then test. I'm using MDX so I will post my code for it, but shouldn't be too hard to figure out.

protected void AttemptRecovery()
{
int ret;

m_device.CheckCooperativeLevel(out ret);

switch (ret)
{
case (int)ResultCode.DeviceLost:
break;
case (int)ResultCode.DeviceNotReset:
try
{
m_device.Reset(m_pp);
deviceLost = false;
}
catch (DeviceLostException)
{
System.Threading.Thread.Sleep(50);
}
break;
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!