Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS Barcode C++ Class Library Help

LBarCode::GetFirstDuplicated

Show in webframe

#include "ltwrappr.h"

L_INT LBarCode::GetFirstDuplicated (nIndex)

L_INT nIndex;

/* index value */

Returns the index of the first barcode, in the class object's barcode data array, that is a duplicate of the barcode at the specified index.

Parameter

Description

nIndex

Index of a barcode in the class object's barcode data array. This is a zero-based index. nIndex must be >= 0 and less than the total number of barcodes read using LBarCode::Read.

Returns

>=0

Index of the barcode, in the class object's barcode data array, that is the first duplicate of the barcode at the specified index.

<0

An error occurred. Refer to Return Codes.

Comments

As an example, a call to LBarCode::Read reads ten barcodes into the class object's barcode data array. LBarCode::IsDuplicated 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 LBarCode::GetFirstDuplicated 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 LBarCode::GetNextDuplicated with nIndex 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.

LBarCode::Read returns the total number of barcodes read.

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:

LBarCode::LBarCode, LBarCode::Read, LBarCode::GetBarCodeDataItem, LBarCode::GetDuplicatedCount, LBarCode::IsDuplicated, LBarCode::GetNextDuplicated, LBarCode::Write, Class Members

Topics:

Programming with LEADTOOLS Barcode

Barcode Function Functions: Finding DuplicatedBarCodes

Example

For complete sample code refer to BarCode demo.

L_INT LBarCode_GetFirstDuplicatedExample(HWND hWnd, LBarCode &LeadBarCode)
{
   L_INT nRet;
   pBARCODEDATA   pBarCodeData=NULL;
   L_INT          nDupIndex, nDupCount;
   if (LeadBarCode.IsDuplicated(3))
   {
      L_TCHAR szBuffer[1024];
      memset(szBuffer, 0, sizeof(szBuffer));
      nDupCount = LeadBarCode.GetDuplicatedCount(3);
      nDupIndex = LeadBarCode.GetFirstDuplicated(3);
      wsprintf(szBuffer, TEXT("This Bar Code is duplicated in %d different locations."), nDupCount);
      MessageBox(hWnd, szBuffer, TEXT("Notice!"), MB_OK);
      if (nDupIndex >= 0)
      {
         pBarCodeData = LeadBarCode.GetBarCodeDataItem(nDupIndex);
         if (!pBarCodeData)
            LBase::DisplayErrorFromList(hWnd);
         memset(szBuffer, 0, sizeof(szBuffer));
         // 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"),
                  pBarCodeData->pszBarCodeData,
                  pBarCodeData->ulType,
                  pBarCodeData->nUnits, 
                  pBarCodeData->rcBarLocation.left,
                  pBarCodeData->rcBarLocation.top,
                  abs(pBarCodeData->rcBarLocation.right - pBarCodeData->rcBarLocation.left),
                  abs(pBarCodeData->rcBarLocation.bottom - pBarCodeData->rcBarLocation.top));
         MessageBox(hWnd, szBuffer, TEXT("BarCode Info."), MB_OK);
         nRet = LeadBarCode.Free(pBarCodeData);
         if(nRet != SUCCESS)
            return nRet;
         pBarCodeData = NULL;
         // find the next (second) duplicated barcode
         nDupIndex = LeadBarCode.GetNextDuplicated(nDupIndex);
         if (nDupIndex >= 0)
         {
            pBarCodeData = LeadBarCode.GetBarCodeDataItem(nDupIndex);
            if (!pBarCodeData)
               LBase::DisplayErrorFromList(hWnd);
            memset(szBuffer, 0, sizeof(szBuffer));
            wsprintf(szBuffer, TEXT("Data is %hs\nType %d\nUnits %d\nPosX %d\nPosY %d\nWidth %d\nHeight %d\n\n"),
                     pBarCodeData->pszBarCodeData,
                     pBarCodeData->ulType,
                     pBarCodeData->nUnits,
                     pBarCodeData->rcBarLocation.left,
                     pBarCodeData->rcBarLocation.top,
                     abs(pBarCodeData->rcBarLocation.right - pBarCodeData->rcBarLocation.left),
                     abs(pBarCodeData->rcBarLocation.bottom - pBarCodeData->rcBarLocation.top));
            MessageBox(hWnd, szBuffer, TEXT("BarCode Info."), MB_OK);
            LeadBarCode.Free(pBarCodeData);
            pBarCodeData = NULL;
         }
      }
   }
   else
      MessageBox(hWnd, TEXT("This Barcode is not duplicated ..."), TEXT("Error!"), MB_OK);
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.