-------------------------------------------------------------------------------------- Display an custom error msg box --------------------------------------------------------------------------------------
| 3441 | // Display an custom error msg box |
| 3442 | //-------------------------------------------------------------------------------------- |
| 3443 | void DXUTDisplayErrorMessage( _In_ HRESULT hr ) |
| 3444 | { |
| 3445 | WCHAR strBuffer[512]; |
| 3446 | |
| 3447 | int nExitCode; |
| 3448 | bool bFound = true; |
| 3449 | switch( hr ) |
| 3450 | { |
| 3451 | case DXUTERR_NODIRECT3D: |
| 3452 | { |
| 3453 | nExitCode = 2; |
| 3454 | wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"Could not initialize Direct3D 11. " ); |
| 3455 | break; |
| 3456 | } |
| 3457 | case DXUTERR_NOCOMPATIBLEDEVICES: |
| 3458 | nExitCode = 3; |
| 3459 | if( GetSystemMetrics(SM_REMOTESESSION) != 0 ) |
| 3460 | wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"Direct3D does not work over a remote session." ); |
| 3461 | else |
| 3462 | wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"Could not find any compatible Direct3D devices." ); |
| 3463 | break; |
| 3464 | case DXUTERR_MEDIANOTFOUND: nExitCode = 4; wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"Could not find required media." ); break; |
| 3465 | case DXUTERR_NONZEROREFCOUNT: nExitCode = 5; wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"The Direct3D device has a non-zero reference count, meaning some objects were not released." ); break; |
| 3466 | case DXUTERR_CREATINGDEVICE: nExitCode = 6; wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"Failed creating the Direct3D device." ); break; |
| 3467 | case DXUTERR_RESETTINGDEVICE: nExitCode = 7; wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"Failed resetting the Direct3D device." ); break; |
| 3468 | case DXUTERR_CREATINGDEVICEOBJECTS: nExitCode = 8; wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"An error occurred in the device create callback function." ); break; |
| 3469 | case DXUTERR_RESETTINGDEVICEOBJECTS: nExitCode = 9; wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"An error occurred in the device reset callback function." ); break; |
| 3470 | // nExitCode 10 means the app exited using a REF device |
| 3471 | case DXUTERR_DEVICEREMOVED: nExitCode = 11; wcscpy_s( strBuffer, ARRAYSIZE(strBuffer), L"The Direct3D device was removed." ); break; |
| 3472 | default: bFound = false; nExitCode = 1; break; // nExitCode 1 means the API was incorrectly called |
| 3473 | |
| 3474 | } |
| 3475 | |
| 3476 | GetDXUTState().SetExitCode(nExitCode); |
| 3477 | |
| 3478 | bool bShowMsgBoxOnError = GetDXUTState().GetShowMsgBoxOnError(); |
| 3479 | if( bFound && bShowMsgBoxOnError ) |
| 3480 | { |
| 3481 | if( DXUTGetWindowTitle()[0] == 0 ) |
| 3482 | MessageBox( DXUTGetHWND(), strBuffer, L"DXUT Application", MB_ICONERROR | MB_OK ); |
| 3483 | else |
| 3484 | MessageBox( DXUTGetHWND(), strBuffer, DXUTGetWindowTitle(), MB_ICONERROR | MB_OK ); |
| 3485 | } |
| 3486 | } |
| 3487 | |
| 3488 | |
| 3489 | //-------------------------------------------------------------------------------------- |
no test coverage detected