Finding Duplicate Barcodes

Take the following steps to add code to the existing project that will let you to find duplicate barcodes:

  1. Start with the program you created in Reading Barcodes.

  2. Define the following global IDs in Ezfunc.h in the BarcodeTutor directory:

    #define IDM_FIND_DUPLICATE       202 

  3. Edit EZFUNC.RC file in the BarcodeTutor directory and add the following lines:

    MAIN_MENU   MENU 
    BEGIN 
       ... 
       ... 
       MENUITEM "Find Duplicate"  IDM_FIND_DUPLICATE 
    END 

  4. In the MainWndProc procedure, add the following code to the switch statement for WM_COMMAND:

    case idm_find_duplicate 
    { 
       l_int ndupindex=0; 
       l_tchar szbuffer[max_path]; 
       memset(szbuffer, 0, max_path); 
       if (l_barcodeisduplicated(&(pbarcodes[0]))) 
       { 
          ndupindex=L_BarCodeGetDuplicated(&(pBarCodes[0])); 
          if (ndupindex>= 0) 
          { 
             // Print the first duplicated barcode data 
             wsprintf(szBuffer, TEXT("Data is %hs\nUnits %d\nPosX %d\nPosY %d\nWidth %d\nHeight %d\n\n"), 
             pBarCodes[nDupIndex].pszBarCodeData, 
             pBarCodes[nDupIndex].nUnits, 
             pBarCodes[nDupIndex].rcBarLocation.left, 
             pBarCodes[nDupIndex].rcBarLocation.top, 
             abs(pBarCodes[nDupIndex].rcBarLocation.right - pBarCodes[nDupIndex].rcBarLocation.left), 
             abs(pBarCodes[nDupIndex].rcBarLocation.bottom - pBarCodes[nDupIndex].rcBarLocation.top)); 
             MessageBox(hWnd, szBuffer, TEXT("BarCode Info."), MB_OK); 
             // find the next (second) duplicated barcode data 
             nDupIndex = L_BarCodeGetNextDuplicated(pBarCodes, nDupIndex); 
             if (nDupIndex >= 0) 
             { 
                wsprintf(szBuffer, TEXT("Data is %hs\nUnits %d\nPosX %d\nPosY %d\nWidth %d\nHeight %d\n\n"), 
                pBarCodes[nDupIndex].pszBarCodeData, 
                pBarCodes[nDupIndex].nUnits, 
                pBarCodes[nDupIndex].rcBarLocation.left, 
                pBarCodes[nDupIndex].rcBarLocation.top, 
                abs(pBarCodes[nDupIndex].rcBarLocation.right - pBarCodes[nDupIndex].rcBarLocation.left), 
                abs(pBarCodes[nDupIndex].rcBarLocation.bottom - pBarCodes[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); 
       } 
    } 
    break; 

  5. Build SimpleLoad.exe.

  6. Run SimpleLoad.exe.

Help Version 20.0.2020.4.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Barcode C API Help