CString GetFullBCErrorText
(
t_BarCode* pBarCode,
ERRCODE eCode
)
{
CString sErrorText;
TCHAR szBuffer[70] = {0};
LPTSTR szErrorMsg = szBuffer;
CString sWrongChar;
LPTSTR szCCError = _T("");
BCGetErrorText(eCode, szBuffer, (sizeof(szBuffer)/sizeof(szBuffer[0]))-1);
if (BCGet_2DCompositeComponent(pBarCode) != eCC_None)
{
BOOL bErrinCC = BCGet_CompSym_ErrorInCC(pBarCode);
szCCError = bErrinCC ? _T("in 2D Composite Component") : _T("in linear component") ;
if (bErrinCC && eCode == W32toTEC(ERROR_NOT_SUPPORTED))
{
szCCError = _T("in Composite Symbology");
szErrorMsg = _T("Composite Component not supported for the selected barcode type");
}
}
if (eCode == W32toTEC(ERROR_INVALID_DATA))
{
INT nPos = BCGet_InvalidDataPos(pBarCode);
CString sData = GetDocument()->GetData();
CString sHex;
if (nPos >= 0 && nPos < sData.GetLength())
{
if (!isgraph(sData.GetAt(nPos)))
sHex.Format(" (ASCII Code 0x%X)", sData.GetAt(nPos) & 0xff);
sWrongChar.Format("'%c' at position %d%s", sData.GetAt(nPos) & 0xff, nPos+1, sHex);
}
}
else if (eCode == NTE_BAD_LEN)
{
INT nLen = BCGetMaxLenOfData(BCGetBCType(pBarCode));
if (nLen > 0)
{
INT nLenCD = BCGetCheckDigits(pBarCode, NULL, 0);
nLenCD = (nLenCD < 0) ? 0 : nLenCD;
sWrongChar.Format(" (needs %d chars)", nLen - nLenCD);
}
}
sErrorText.Format(_T("Error %s: %s%s!"), szCCError, (LPCSTR) szErrorMsg, sWrongChar);
return sErrorText;
}