Writing Barcodes

Take the following steps to add code to an existing project that will let you to write 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_WRITE_BARCODES       201
 

 

3.

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

 

MAIN_MENU   MENU

BEGIN

   ...

   ...
   MENUITEM "Write Barcode"   IDM_WRITE_BARCODES

END

 

4.

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

      case IDM_WRITE_BARCODES:
         {
            BARCODE1D Bar1d;

            memset(&Bar1d, 0, sizeof(BARCODE1D));

            Bar1d.uStructSize = sizeof(BARCODE1D);

            Bar1d.bErrorCheck = TRUE;

            Bar1d.bOutShowText = TRUE;

 

            BARCODEDATA BarData;

            memset(&BarData, 0, sizeof(BARCODEDATA));

            BarData.uStructSize = sizeof(BARCODEDATA);

            BarData.nUnits = BARCODE_SCANLINES_PER_PIXELS;

            SetRect(&BarData.rcBarLocation, 100, 100, 350, 200);

            BarData.pszBarCodeData = "012345678901";

            BarData.nSizeofBarCodeData = (L_INT)strlen(BarData.pszBarCodeData);

            BarData.ulType = BARCODE_1D_EAN_13;

 

            BARCODECOLOR BarColor;

            memset(&BarColor, 0, sizeof(BARCODECOLOR));

            BarColor.uStructSize = sizeof(BARCODECOLOR);

            BarColor.dwColorBar = RGB(0, 0, 0);

            BarColor.dwColorSpace = RGB(255, 255, 255);

 

            L_INT nRet = L_BarCodeWrite(&LeadBitmap,

                                        &BarData,

                                        &BarColor,

                                        0, &Bar1d, NULL, NULL, NULL, NULL);

            if (nRet == SUCCESS)

               InvalidateRect(hWnd, NULL, TRUE);

            else

               MessageBox(hWnd, TEXT("Failure during writing linear barcodes"), TEXT("Error!"), MB_OK);
         }
         break;

 

5.

Build SimpleLoad.exe.

6.

Run SimpleLoad.exe.