Пример #1
0
LPCTSTR AFXAPI AfxGetFullScodeString(SCODE sc)
{
	static TCHAR szBuf[128];
	LPCTSTR lpsz;
	if ((lpsz = AfxGetScodeString(sc)) != NULL)
	{
		// found exact match
		wsprintf(szBuf, _T("%s ($%08lX)"), lpsz, sc);
	}
	else if ((lpsz = AfxGetScodeRangeString(sc)) != NULL)
	{
		// found suitable range
		wsprintf(szBuf, _T("range: %s ($%08lX)"), lpsz, sc);
	}
	else
	{
		// not found at all -- split it up into its parts
		wsprintf(szBuf, _T("severity: %s, facility: %s ($%08lX)"),
			AfxGetSeverityString(sc), AfxGetFacilityString(sc), sc);
	}
	return szBuf;
}
Пример #2
0
LPCTSTR AFXAPI AfxGetFullScodeString(SCODE sc)
{
	static TCHAR szBuf[128] = _T("<scode string too long>");

	LPCTSTR lpsz;
	if ((lpsz = AfxGetScodeString(sc)) != NULL)
	{
		// found exact match
		static const TCHAR szFormat[] = _T("%s ($%08lX)");
		if( lstrlen(lpsz) + _countof(szFormat) - 2 /*%s*/ - 6 /*$%08lX*/ + 8 /*size of long value*/ < _countof(szBuf) )
		{
			_stprintf_s(szBuf, _countof(szBuf), szFormat, lpsz, sc);
		}
	}
	else if ((lpsz = AfxGetScodeRangeString(sc)) != NULL)
	{
		// found suitable range
		static const TCHAR szFormat[] = _T("range: %s ($%08lX)");
		if( lstrlen(lpsz) + _countof(szFormat) - 2 /*%s*/ - 6 /*$%08lX*/ + 8 /*size of long value*/ < _countof(szBuf) )
		{
			_stprintf_s(szBuf, _countof(szBuf), szFormat, lpsz, sc);
		}
	}
	else
	{
		// not found at all -- split it up into its parts
		LPCTSTR lpszSeverity = AfxGetSeverityString(sc);
		LPCTSTR lpszFacility = AfxGetFacilityString(sc);
		static const TCHAR szFormat[] = _T("severity: %s, facility: %s ($%08lX)");

		if( lstrlen(lpszSeverity) + lstrlen(lpszFacility) + _countof(szFormat) - 2 /*%s*/ - 6 /*$%08lX*/ + 8 /*size of long value*/ < _countof(szBuf) )
		{
			_stprintf_s(szBuf, _countof(szBuf), szFormat, lpszSeverity, lpszFacility, sc);
		}
	}
	return szBuf;
}