Abstract: This article describes how to use Delphi to call the bar code ActiveX component to print the bar code.
1. Preface
The most recent project needs to print the barcode in a fixed format after scanning. Bar code printing software customers are used to use barrier. To maintain their habits and reduce development risks, they decided to use Delphi to call barrier to print the bar code label function.
This function focuses on:
A) print in bartender format
B) The format must be changed.
2. Design labels
A) create a blank tag.
B) add a bar code control and a text control to the screen.
C) Select the bar code control, double-click (or right-click, properties), and open the Properties window. Click "advanced" and select the "Share/Name" page, in the Share Name field, enter the bar code control name "barcode1". Click "OK" to complete the modification. This step defines the object names accessed in Delphi (or other languages such as VB.
D) In the same step, set the text control name to "text1"
E) save it as "C: \ test. BTW"
3. Import ActiveX Components
A) Open Delphi (Version 5.0 and later, others are not tested)
B) select project> Import Type Library from the menu)
C) In the pop-up window, list the database types that can be imported. Find "Bartender 7.75" and select
D) The name of the class to be imported will be listed in the class names. Because the class name here will be repeated with the existing class name in the system, copy all the names, add BT to the front of the type name. For example, change tformat to tbtformat.
E) after the class name is modified, click "Install" (install)
F) The system will install components on the ActiveX control page.
4. Call bartender to print
A) create an applicationProgram
B) drag a tbtapplication control (ActiveX page) on the form and name it btapp1
C) place a tbutton control on the form and name it btn1. Double-click btn1 to generate an event.
D) Fill in the eventCodeAs follows:
Procedure tform1.btn1click (Sender: tobject );
Begin
With btapp1.formats. Open ('C: \ test. btw', true, '') Do
// Open the Tag file
Begin
Setnamedsubstringvalue ('barcode1', '20140901'); // set the value
Setnamedsubstringvalue ('text1', 'Hello bartender! ');
Printout (false, false); // print
Close (btdonotsavechanges); // close and do not save
End;
Btapp1.quit (btdonotsavechanges); // exit the end;
E) should I be able to work now ?... For more information, see the source code of the introduced Type Library (bartender_tlb.pas)