We use cookies to provide you with the best experience and functionality on our website. By continuing to use the site, you are agreeing to our use of cookies.   

Delphi
Barcodes in projects

EnterpriseInfoTo use this functionality you require the Enterprise Edition

Delphi

How to use barcodes in Delphi

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.

1. Add ActiveBarcode to the Delphi development environment


First import the ActiveBarcode Control into a package. Launch the function "Import Component" from the menu "Component".

Barcode, Delphi

The "Component dialog" appears:

Barcode, Delphi

Select "Import ActiveX control" and click "Next". Now a list of the available controls will be shown:

Barcode, Delphi

Select "ActiveBarcode" from that list and click "Next". A page for component setup will be shown:

Barcode, Delphi

You don't need to change something here. Click "Next". A page for "Create Unit" appears.

Barcode, Delphi

Select "Install to new package" here and click on "Next". The "New Package" dialog is showing up:

Barcode, Delphi

Enter a name for the new package, e.g. ActiveBarcode. Then click "Finish". Now ActiveBarcode is added as a component to the new package. Now you must compile the package. Select the function "Build ActiveBarcode" from the menu "Project":

Barcode, Delphi



2. An example of how to use ActiveBarcode now:

Create a new project: "File" - "New" - "VCL Forms Application":

Barcode, Delphi

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:

Barcode, Delphi

Select TBarcode and place the component on the form. Sadly, Delphi adds the barcode object with a black background color.

Barcode, Delphi

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.

Barcode, Delphi

Voila, the barcode object looks fine now:

Barcode, Delphi

In this example we add one more control, a TEdit to the form. Now your form might look as follows:

Barcode, Delphi

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.

Barcode, Delphi

That's it. Now launch the program:

Barcode, Delphi

Change the content of the edit field to change the barcode.

Programming:
Setting properties is very simple. Some examples:

Barcode1.Text := '123456789012';
Barcode1.BackColor := clWhite;
Barcode1.ForeColor := clBlack;
Using the Picture Property:
Copy the barcode to a image object:
Image1.Picture.Bitmap.Height := Barcode1.Height;
Image1.Picture.Bitmap.Width := Barcode1.Width;
Barcode1.Picture.PictureAdapter := nil; // delphi workaround
Image1.Picture.Bitmap.Canvas.Draw(0,0,Barcode1.Picture.graphic);
Clipboard:
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.PictureAdapter := nil; // delphi workaround
Image1.Picture.Bitmap.Canvas.Draw(0,0,Barcode1.Picture.graphic);
Clipboard.Assign(Image1.Picture.Bitmap);

This manual was created by Frank Horn

Search this site with Bing:
| Home | Shop | Download | E-Mail | Datenschutz | Imprint | Version 6.1.0 |
Web DesignszCWs 2.0.12.597
Web design & developement:
www.frank-horn.com

Copyright
Frank HornActiveBarcode Generator App
Web design
Documentation
Copyright Frank Horn
&
Lars SchenkActiveBarcode Object
Web- & server component
Command line
Copyright Lars Schenk

All trademarks and product names mentioned are the property of their respective owners.