This example shows the error handling concept of TBarCode. If BCCreate() returns any value other than zero (ErrOK) you might use the following function to get detailled information about the occured error.
For retrieving error texts see also BCGetErrorTextExt().
More...
This example shows the error handling concept of TBarCode. If BCCreate() returns any value other than zero (ErrOK) you might use the following function to get detailled information about the occured error.
For retrieving error texts see also BCGetErrorTextExt().
CString GetFullBCErrorText
(
)
{
CString sErrorText;
TCHAR szBuffer[70] = {0};
LPTSTR szErrorMsg = szBuffer;
CString sWrongChar;
LPTSTR szCCError = _T("");
BCGetErrorText(eCode, szBuffer, (
sizeof(szBuffer)/
sizeof(szBuffer[0]))-1);
{
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))
{
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)
{
if (nLen > 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;
}