文档详情

BarTenderActiveX在Delphi和VB下调用数据库的实例.docx

发布:2020-10-24约2.71万字共27页下载文档
文本预览下载声明
BarTender ActiveX 在Delphi和VB下调用数据库的实例 (转贴) BarTender ActiveX 封装了大量的函数和属性,其中包括对数据库的调用。下面通过在 Delphi和VB下的实例给出其调用方法。 先看 Delphi的例子。 首先打开BarTender生成一个标签,并正确添加数据库,设置其子串共享名为 domainl 。 打开Delphi ,创建一个工程。 声明全局变量 btapp , btformat , btdb。 在 FormCreate 过程中引用 BarTender 。 btapp:=createoleobject(Bartender.application.7); btapp.visible:=false; 5 .向窗体中加入一个 button,设置其Caption值为打印”,其name为print,为其 click过程添加代码: btformat:=btapp.formats.open(d:\bartender\format1.btw, true, ); btdb:= btformat.databases.item(1); btformat.printout(0,0); btformat.close(1); 6.向FormCloseQuery 中加入代码: try btapp.quit(1) except application.terminate end; 7 .保存并运行。 源代码如下: uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, OleCtrls, DBOleCtl, BARCODELib_TLB, ComObj,OleCtnrs, ExtCtrls, ComCtrls, DBCtrls; type TForm1 = class(TForm) print: TButton; Label1: TLabel; procedure FormCreate(Sender: TObject); procedure printClick(Sender: TObject); private ( Private declarations } public ( Public declarations } btapp:variant; btformat:variant; btdb:variant; end; var Forml: TForml; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin btapp:=createoleobject(Bartender.application.7); btapp.visible:=false; end; procedure TForm1.printClick(Sender: TObject); begin btformat:=btapp.formats.open(d:\bartender\format1.btw, true, ); btdb:= btformat.databases.item(1); btformat.printout(0,0); btformat.close(1); end; procedure TForm1.FormCloseQuery(Sender: Tobject; CanClose: Boolean); begin try btapp.quit(1) except application.terminate end; end; end. 下面我们再通过一个简单的例子说明 BarTender ActiveX 在VB下如何调用数据库,因 此在此例中我们直接为 format1.btw指定了数据库域,并指定了文件存放的路径。 首先打开BarTender生成一个标签,并正确添加数据库,设置其子串共享名为 domain1 。 在VB中新建一个工程, 保存。工程|引用”中选中BarTender7.0 ,然后打开代码窗口, 选择通用/声明”,添加下列声明: Dim btapp As BarTender.Application Dim btformat As BarTender.Format Dim btdb As BarTender.Database 在Form/Load”中加入代码: Private Sub Form_Load() Set btapp = CreateObject(bartender.application) btapp.Visible = False End Sub 在
显示全部
相似文档