-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDXTrace.inl
49 lines (40 loc) · 1.72 KB
/
DXTrace.inl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
DX_CHAR strBufferLine[128];
DX_CHAR strBufferError[256];
DX_CHAR strBuffer[BUFFER_SIZE];
DX_SPRINTF_S( strBufferLine, 128, DX_STR_WRAP("%lu"), dwLine );
if( strFile )
{
DX_SPRINTF_S( strBuffer, BUFFER_SIZE, DX_STR_WRAP(STR_FMT_SPEC "(" STR_FMT_SPEC "): "), strFile, strBufferLine );
DX_OUTPUTDEBUGSTRING( strBuffer );
}
size_t nMsgLen = (strMsg) ? DX_STRNLEN_S( strMsg, 1024 ) : 0;
if( nMsgLen > 0 )
{
DX_OUTPUTDEBUGSTRING( strMsg );
DX_OUTPUTDEBUGSTRING( DX_STR_WRAP(" ") );
}
DX_SPRINTF_S( strBufferError, 256, DX_STR_WRAP(STR_FMT_SPEC " (0x%0.8x)"), DX_GETERRORSTRING(hr), hr );
DX_SPRINTF_S( strBuffer, BUFFER_SIZE, DX_STR_WRAP("hr=" STR_FMT_SPEC), strBufferError );
DX_OUTPUTDEBUGSTRING( strBuffer );
DX_OUTPUTDEBUGSTRING( DX_STR_WRAP("\n") );
#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
if( bPopMsgBox )
{
DX_CHAR strBufferFile[MAX_PATH];
DX_STRCPY_S( strBufferFile, MAX_PATH, DX_STR_WRAP("") );
if( strFile )
DX_STRCPY_S( strBufferFile, MAX_PATH, strFile );
DX_CHAR strBufferMsg[1024];
DX_STRCPY_S( strBufferMsg, 1024, DX_STR_WRAP("") );
if( nMsgLen > 0 )
DX_SPRINTF_S( strBufferMsg, 1024, DX_STR_WRAP("Calling: " STR_FMT_SPEC "\n"), strMsg );
DX_SPRINTF_S( strBuffer, BUFFER_SIZE, DX_STR_WRAP("File: " STR_FMT_SPEC "\nLine: " STR_FMT_SPEC "\nError Code: " STR_FMT_SPEC "\n" STR_FMT_SPEC "Do you want to debug the application?"),
strBufferFile, strBufferLine, strBufferError, strBufferMsg );
int nResult = DX_MESSAGEBOX( GetForegroundWindow(), strBuffer, DX_STR_WRAP("Unexpected error encountered"), MB_YESNO | MB_ICONERROR );
if( nResult == IDYES )
DebugBreak();
}
#else
UNREFERENCED_PARAMETER(bPopMsgBox);
#endif
return hr;