Delphi
Barcodes in Delphi projects
How to use barcodes in Delphi
Delphi 2005, 2006, 2007, 2009, 2010, XE, XE2, XE3, XE4, XE5, XE6, XE7, XE8, 10 Seattle, 10.1 Berlin, 10.2 Tokyo, 10.3 Rio
You can use ActiveBarcode in Delphi like any other control (e.g. like a button).
First you have to add the ActiveBarcode control into the Delphi development environment.
Create a new project: "File" - "New" - "VCL Forms Application":
To place ActiveBarcode on a form you select the ActiveBarcode Control from the tool palette. You'll find this under "ActiveX" as a "TBarcode" component:
Select TBarcode and place the component on the form. Sadly, Delphi adds the barcode object with a black background color.
But, no problem, simply fix this. In the object inspector you can customize the properties of the component. So set the background color to white.
Voila, the barcode object looks fine now:
In this example we add one more control, a TEdit to the form. Now your form might look as follows:
Next we link the edit field directly to the control. Open the source code for the "textchange" event by double clicking the edit field. This event always is called, if the contents of the edit field are changed. Ideally for our example. We give this update immediately to the control.
That's it. Now launch the program:
Change the content of the edit field to change the barcode.
Programming:
Setting properties is very simple. Some examples:
Barcode1.Text := '123456789012';Using the Picture Property:
Barcode1.BackColor := clWhite;
Barcode1.ForeColor := clBlack;
Copy the barcode to a image object:
Image1.Picture.Bitmap.Height := Barcode1.Height;Clipboard:
Image1.Picture.Bitmap.Width := Barcode1.Width;
Barcode1.Picture.CleanupInstance;
Image1.Picture.Bitmap.Canvas.Draw(0,0,Barcode1.Picture.graphic);
Copy the current barcode to the clipboard. Metafile (WMF):
Barcode1.CopyToClipboard;Bitmap:
Image1.Picture.Bitmap.Height := Barcode1.Height;
Image1.Picture.Bitmap.Width := Barcode1.Width;
Barcode1.Picture.CleanupInstance;
Image1.Picture.Bitmap.Canvas.Draw(0,0,Barcode1.Picture.graphic);
Clipboard.Assign(Image1.Picture.Bitmap);