Im having trouble resetting the D3D device after I alt teab out of the game. Im using .X file for my meshes and when it loads the first time, It works but when I press Alt-Tab and try going back in. The program just gives be a black window. It doesnt even go back into Full Screen mode agian.

Code:
if(FAILED(hr = g_pd3dDevice->TestCooperativeLevel()))
{

  if(hr == D3DERR_DEVICELOST)
  {
    return;
  }

  if(hr == D3DERR_DEVICENOTRESET)
  {
    
    invalidateDeviceObjects();
    hr = g_pd3dDevice->Reset(&g_d3dpp);
    
    if(FAILED(hr))
    {
      return; //IT KEEPS FAILING HERE!!!!!
    }
    
    restoreDeviceObjects();
  }
  return;
}
Any Suggestions????