L_BarCodeGetDuplicated

#include "ltbar.h"

L_INT EXT_FUNCTION L_BarCodeGetDuplicated(pBarCodeDataItem)

pBARCODEDATA pBarCodeDataItem;

/* pointer to a BARCODEDATA structure */

Returns the index of the first barcode that is a duplicate of the specified barcode.

Parameter

Description

pBarCodeDataItem

Pointer to the BARCODEDATA structure that contains barcode information.

Returns

>= 0

The index of the duplicated barcode.

< 0

An error occurred. Refer to Return Codes.

Comments

To determine whether a barcode is duplicated, use the L_BarCodeIsDuplicated function. If a barcode is duplicated, L_BarCodeGetDuplicated will return the index of the first barcode in the array after the specified barcode, which is a duplicate of the specified barcode.

If you know the index of a barcode within an array, you can get the index of the first duplicate of the specified barcode using L_BarCodeGetFirstDuplicated.

Required DLLs and Libraries

LTBAR

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

L_BarCodeRead, L_BarCodeWriteExt, L_BarCodeFree, L_BarCodeIsDuplicated, L_BarCodeGetNextDuplicated, L_BarCodeVersionInfo, L_BarCodeGetFirstDuplicated, L_BarCodeWriteExt2

Topics:

Programming with LEADTOOLS Barcode

BarCode API Function Groups

Example

For complete sample code refer to MFCBar32 demo.

 

L_INT TestDuplicatedBarCode(HWND hWnd, pBARCODEDATA L_FAR * ppBarCodeData)
{
   L_INT nDupIndex=0;
   L_TCHAR szBuffer[256];

   if (!ppBarCodeData) return FAILURE;
   memset(szBuffer, 0, sizeof(szBuffer));

   if (L_BarCodeIsDuplicated(&(*ppBarCodeData)[2]))
   {
      nDupIndex = L_BarCodeGetDuplicated(&(*ppBarCodeData)[2]);
      if (nDupIndex >= 0)
      {
         // Print the first duplicated barcode data
         wsprintf(szBuffer, TEXT("Data is %hs\nType %d\nUnits %d\nPosX %d\nPosY %d\nWidth %d\nHeight %d\n\n"),
                  (*ppBarCodeData)[nDupIndex].pszBarCodeData, (*ppBarCodeData)[nDupIndex].ulType, (*ppBarCodeData)[nDupIndex].nUnits, 
                  (*ppBarCodeData)[nDupIndex].rcBarLocation.left,
                  (*ppBarCodeData)[nDupIndex].rcBarLocation.top,
                  abs((*ppBarCodeData)[nDupIndex].rcBarLocation.right - (*ppBarCodeData)[nDupIndex].rcBarLocation.left),
                  abs((*ppBarCodeData)[nDupIndex].rcBarLocation.bottom - (*ppBarCodeData)[nDupIndex].rcBarLocation.top));

         MessageBox(hWnd, szBuffer, TEXT("BarCode Info."), MB_OK);

         // find the next (second) duplicated barcode data
         nDupIndex = L_BarCodeGetNextDuplicated(*ppBarCodeData, nDupIndex);
         
         if (nDupIndex >= 0)
         {
            wsprintf(szBuffer, TEXT("Data is %hs\nType %d\nUnits %d\nPosX %d\nPosY %d\nWidth %d\nHeight %d\n\n"),
                     (*ppBarCodeData)[nDupIndex].pszBarCodeData, (*ppBarCodeData)[nDupIndex].ulType, (*ppBarCodeData)[nDupIndex].nUnits, 
                     (*ppBarCodeData)[nDupIndex].rcBarLocation.left,
                     (*ppBarCodeData)[nDupIndex].rcBarLocation.top,
                     abs((*ppBarCodeData)[nDupIndex].rcBarLocation.right - (*ppBarCodeData)[nDupIndex].rcBarLocation.left),
                     abs((*ppBarCodeData)[nDupIndex].rcBarLocation.bottom - (*ppBarCodeData)[nDupIndex].rcBarLocation.top));

            MessageBox(hWnd, szBuffer, TEXT("BarCode Info."), MB_OK);
         }
      }
      
      if (nDupIndex < 0)
      {
         wsprintf(szBuffer, TEXT("An error occurred \nError Code = %d\n"), nDupIndex);
         MessageBox(hWnd, szBuffer, TEXT("Notice!"), MB_OK);
      }
   }
   else
   {
      wsprintf(szBuffer, TEXT("This Barcode is not duplicated ..."));
      MessageBox(hWnd, szBuffer, TEXT("Notice!"), MB_OK);
   }

   return nDupIndex;
}