I am using the Microsoft.DirectX and Microsoft.DirectX.Direct3D references to do some drawing on my form. While I am running the program and the user presses CTRL ALT DEL in Windows XP and brings up the “Windows Security” form, when returning back to the Form, a DeviceLostException is thrown and when trying to handle this exception there seems to be no way to get it back.
I have done a little research into the matter and have tried several coding solutions.
try
{
_d3ddevice.Present();
}
catch
{
DeviceLost = true;
}
if (DeviceLost)
{
AttemptRecovery();
}
this.Invalidate();
ReadKeyboard();
base.OnPaint(e);
}
private void AttemptRecovery()
{
try
{
_d3ddevice.TestCooperativeLevel();
}
catch (DeviceLostException)
{
Application.Exit();
}
catch (DeviceNotResetException)
{
try
{
_d3ddevice.Reset(_params);
DeviceLost = false;
InitGraphics();
CameraPositioning();
VertexDeclaration();
IndicesDeclaration();
}
catch (DeviceLostException)
{
}
}
}
When the program calls TestCooperativeLevel(), it said online if it catches the DeviceLostException again that there is no point in trying to reset the device.
What can I do to reset the device and continue drawing in my form?
2 things in 4 points :
Resetmethod.