Take the following steps to add code to the existing project that will let you to find duplicate barcodes:
Start with the program you created in Reading Barcodes.
Define the following global IDs in Ezfunc.h in the BarcodeTutor directory:
#define IDM_FIND_DUPLICATE 202 Edit EZFUNC.RC file in the BarcodeTutor directory and add the following lines:
MAIN_MENU MENUBEGIN......MENUITEM "Find Duplicate" IDM_FIND_DUPLICATEEND
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 datawsprintf(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 datanDupIndex = 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;
Build SimpleLoad.exe.
Run SimpleLoad.exe.