L_BarCodeGetFirstDuplicated

#include "ltbar.h"

L_INT EXT_FUNCTION L_BarCodeGetFirstDuplicated(pBarCodeData, nIndex)

pBARCODEDATA pBarCodeData;

/* pointer to the BARCODEDATA structures */

L_INT nIndex;

/* current barcode index*/

Returns the index of the first barcode in the array that is a duplicate of the barcode at index nIndex.

Parameter

Description

pBarCodeData

Pointer to an array of BARCODEDATA structures that contain barcode information for a bitmap. This parameter is the same array returned by L_BarCodeRead.

nCurIndex

Index of a barcode. This index is zero based.

Returns

>=0

An index of duplicated barcode.

< 0

An error occurred. Refer to Return Codes.

Comments

As an example, a call to L_BarCodeRead reads ten barcodes into a BARCODEDATA array. L_BarCodeIsDuplicated is called for the item at index 3 in the array, and TRUE is returned. Therefore one or more barcodes in the array are duplicates of the specified item.

Calling L_BarCodeGetFirstDuplicated returns the index of the first barcode in the array that is a duplicate of the barcode at index 3 in the array. Suppose this value is 0. The barcode present at index zero in the array is the first duplicate of the barcode at index 3.

Calling L_BarCodeGetNextDuplicated with nCurIndex set to 3 will return the index of the next barcode in the array that is a duplicate of the barcodes at index 0 and 3. Suppose this value is 9. Therefore the barcodes at index 0, index 3, and index 9 of the array are all duplicates.

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_BarCodeGetDuplicated, L_BarCodeVersionInfo, L_BarCodeGetNextDuplicated, L_BarCodeWriteExt2

Topics:

Programming with LEADTOOLS Barcode

BarCode API Function Groups

Example

For complete sample code refer to MFCBar32 demo.

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

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

   // suppose you have more than 5 in ppBarCodeData of BARCODEDATA
   if (L_BarCodeIsDuplicated(&(*ppBarCodeData)[5]))
   {
      nDupIndex = L_BarCodeGetFirstDuplicated(*ppBarCodeData, 5);
      if (nDupIndex >= 0)
      {
         // Print the first duplicated bar code 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));
      }
      else
         wsprintf(szBuffer, TEXT("An error occurred in L_BarCodeGetFirstDuplicated\nError Code = %d\n"), nDupIndex);
   }
   else
      wsprintf(szBuffer, TEXT("This Bar Code does not duplicated ..."));

   MessageBox(hWnd, szBuffer, ((nDupIndex >= 0) ? TEXT("BarCode Info.") : TEXT("Notice!")), MB_OK);

   return nDupIndex;
}