周國瑞
(上海出版印刷高等專科學(xué)校,上?!?00093)
基于Codesoft條碼的自動打印控件設(shè)計與應(yīng)用
周國瑞
(上海出版印刷高等專科學(xué)校,上海200093)
Codesoft軟件是一款流行的條碼設(shè)計打印軟件,廣泛應(yīng)用于生產(chǎn)出版等各個領(lǐng)域的條碼打印設(shè)計。這個軟件支持一維碼和二維碼的黑白及彩色打印,它只能打印事先設(shè)計好的標簽文件,或者根據(jù)設(shè)定數(shù)據(jù)源打印數(shù)據(jù)。實際上,在實際應(yīng)用中一些打印是不可預(yù)知的,比如超市中客戶隨時購買商品的打印、移動產(chǎn)品生產(chǎn)時讀取存儲器中的序列號并打印等。為解決這一問題,文章結(jié)合Codesoft用VB開發(fā)了一個可以用于其他多種編程語言的自動打印控件,該控件使用方便,只要注冊后調(diào)用OpenCS、OpenLabelFile、SetLabelFieldValue、PrintLabel、CloseCS五個接口即可。
VBCodesoft條形碼控件打印
隨著條碼打印行業(yè)的發(fā)展,條碼打印軟件種類繁多,目前市場上流行的Codesoft條碼打印軟件應(yīng)用比較廣泛,它設(shè)計和應(yīng)用簡單,打印的標簽比較漂亮,受到條碼需求客戶的青睞。但它只能打印事先設(shè)計好的標簽文件,或者根據(jù)設(shè)定數(shù)據(jù)源打印數(shù)據(jù)[1-2]。實際上,在實際應(yīng)用中一些打印是不可預(yù)知的,比如超市中客戶隨時購買商品的打印、移動產(chǎn)品生產(chǎn)時讀取存儲器中的序列號并打印等。為解決這一問題,本文結(jié)合Codesoft用VB開發(fā)了一個可以用于其他多種編程語言的自動打印控件。
圖1 選擇工程控件類型
首先安裝Codesoft軟件,不妨安裝在D:Program FilesCS6文件夾。打開VB應(yīng)用程序,新建ActiveX DLL工程[3](如圖1),并以LabelPrint工程名保存,然后把Class Modules類模塊下的Class1改名為LabelPrint(如圖
定稿日期:2015-05-122);添加引用D:Program FilesCS6lpp2.tlb,并選擇TK Labeling ActiveX 6.0(如圖3)。
圖2 命名代碼類
圖3 選擇添加Codesoft類型庫
Option Explicit’顯性定義全局變量
‘打開Codesoft服務(wù)程序
‘關(guān)閉Codesoft服務(wù)程序
‘模板文本變量值修改函數(shù)
‘模板文本變量值修改函數(shù)
‘打印函數(shù),打印一頁并換頁
本文給出了怎樣用VB編寫條碼自動打印控件的方法,在其他VC++、C#、BCB等語言編程時可以注冊調(diào)用LabelPrint.DLL控件實現(xiàn)條碼的自動控制打印。該控件支持一維碼和二維碼的黑白和彩色標簽打印。使用時只要用Codesoft設(shè)計好打印模板并定義動態(tài)文本變量,在打印時加載設(shè)計好的模板并修改變量的值打印就可以了。本文還提供了怎樣用VB設(shè)計ActiveX DLL控件的方法。
[1]CODESOFT V2012-用戶指南[EB/OL].http://www. codesoft.net.cn.
[2]CODESOFT V2014-手冊[EB/OL].http://www.codesoft. net.cn.
[3]劉新民等.Visual Basic 6.0程序設(shè)計[M].北京:清華大學(xué)出版社,2004.
Design and Application of Automatic Printing Control Based on Codesoft bar Code
ZHOU Guo-rui
(Shanghai Publication Printing College Level Specialty School,Shanghai 200093袁China
Codesoft,a popular software for barcode printing designs,is widely used in the fields of production,publishing,etc.,which supports one-dimensional and two-dimensional printing in black-white and color.But,it can only print pre-designed label or data based on data source.In practice,what is unpredictable to print the bar code for customers and the serial number from the storager of the mobile equipment when being produced.To sovle this problem,this paper gives an activeX DLL control based on VB and Codesoft,which can be used in various programming languages.This printing control is easy to use,only interfaces of OpenCS,OpenLabelFile,SetLabelFieldValue,PrintLabel,and CloseCS need to be invoked after it is registered.
VB;Codesoft;Barcode;ActiveX DLL;Printing
TP319
A
1008-1739(2015)11-56-2