TTMSFNCWXBarcode

Good afternoon to all,
im a AdvStringGrid i have a ean product code and description. There's a way to insert into an AdvStringGrid's columns the relative barcode with TTMSFNCWXBarcode component. If It's possibile .... how i can do ?
One solution is use a bitmap into string grid .....

Thank's for reply...

Best regards
Daniele

Hi,

If you want to add generated barcode images to your grid, then you can try the following:

  1. Use a single instance of TTMSFNCWXBarcode and set the visibility to False, so it won't appear on your form but it can still be used for generating images.
  2. TTMSFNCWXBarcode has a GetBarcode method that is synchronous on desktop platforms. It allows you to generate barcodes one-by-one. It returns a TTMSFNCBitmap, which can be assigned to a TPicture directly in VCL.
  3. Take the EAN numbers from your grid and run them through the GetBarcode method:
procedure TForm1.GenerateBarcodes;
var
  I: Integer;
  bmp: TTMSFNCBitmap;
begin
  for I := YourStartingIndex to AdvStringGrid1.RowCount - 1 do
  begin
    bmp := TMSFNCWXBarcode1.GetBarcode(AdvStringGrid1.Cells[ColumnOfEANCode, I]);
    try
      AdvStringGrid1.CreatePicture(ColumnOfBarcodeImage, I, True, noStretch, 0, haCenter, vaCenter).Assign(bmp);
    finally
      bmp.Free;
    end;
  end;
end;

You can tweak the settings as needed in CreatePicture.

Thank you so much for quick and clear answer !!
Have you any suggest in order to print the generated barcode? (from grid and/or from barcode component).

Thank you for, precious, help.

Daniele

It depends how do you want to print these barcodes exactly. Is it just the barcode alone (optionally with some text)?
You could try TTMSFNCPrinter, it supports adding TTMSFNCBitmaps to a print document. See the documentation here along with a sample that shows how to add text & bitmap: TTMSFNCPrinter - TMS FNC Core

If you want to print the whole grid then you might want to check out the TAdvStringGrid printing demo. You can find it under Demo\AdvStringGrid\asg9.

Good morning, excuse me for same delay ... i had need time to made some test.
My need is print a barcode on epson tm-30 that have a roll paper of 80mm width.
The barcode rectangle is 35mmx20mm and i try to print this barcode with TTMSFNCPrinter. Before i create a barcode with TMSFNCWXBarcode1.GetBarcode(AdvStringGrid1.Cells[ColumnOfEANCode, I]) and print it with TMSFNCPrinter.Graphics.DrawBitmap.
It's do the job (meaning the barcode is printed) but is not clear ..... seems "blurred" It's not readable with the barcode scanner.
Do you have some suggestion ??
Thank you for all
Best regards
Daniele

I'm not sure I understand the situation correctly. The resulting barcode is 35mmx20mm and you are trying to fit that to 80mm or are you printing it as 35x20mm and it's still blurry?

If it's the first case:
The size of the barcode is directly relating to the size of the TTMSFNCWXBarcode control, meaning you'll get the resulting TTMSFNCBitmap in the same size. Perhaps you can try to increase the size of the control and see if that helps? Make sure to set the TTMSFNCWXBarcode.Scale property too to a bigger value (2 or even higher if necessary, whatever fits into the size you need) to avoid a tiny barcode.

Good afternoon,
thank you for reply.
I'm in the second case, i need to print the generated barcode in 35x20mm area.

I'll try working with scale property in order to see if the quality will be better.

Thank you

Regards
Daniele