L
liuying1129
Unregistered / Unconfirmed
GUEST, unregistred user!
我现在要把一个打印单元封装为DLL,可试了很久老是出现内存读写错误,只好求助各位大侠了!
打印单元的源代码:
unit Unit_ywryda_print;
interface
uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls, DB, ADODB;
type
Tfrm_ywryda_print = class(TQuickRep)
PageHeaderBand1: TQRBand;
QRLabel1: TQRLabel;
DetailBand1: TQRBand;
QRDBText3: TQRDBText;
QRShape8: TQRShape;
QRDBText1: TQRDBText;
QRDBText5: TQRDBText;
QRDBText4: TQRDBText;
QRDBText6: TQRDBText;
QRDBText7: TQRDBText;
QRShape12: TQRShape;
QRShape14: TQRShape;
QRShape15: TQRShape;
QRShape16: TQRShape;
ColumnHeaderBand1: TQRBand;
QRLabel2: TQRLabel;
QRLabel8: TQRLabel;
QRLabel7: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRShape1: TQRShape;
QRShape3: TQRShape;
QRShape5: TQRShape;
QRShape6: TQRShape;
QRShape7: TQRShape;
ADOQuery1: TADOQuery;
procedure InitData;
private
public
end;
var
frm_ywryda_print: Tfrm_ywryda_print;
procedure show_ywryda_print;
implementation
{$R *.DFM}
{ Tfrm_ywryda_print }
function adoconnect_dl:TADOConnection;external 'ADOConnectionpubLib.dll' name 'adoconnect_dl';
procedure Tfrm_ywryda_print.InitData;
begin
ADOQuery1.Connection:=adoconnect_dl;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:='select rydah as 人员档案号,dwbm as 单位编码,dwmc as 单位名称,'+
' xm as 姓名,sfzh as 身份证号,'+
' xb as 性别,wtsnx as 委托书年限,wtsfw as 委托书范围,'+
' sfyfrdbwtsyj as 是否有法人代表委托书原件,'+
' sfyxsrysfzfyj as 是否有销售人员身份证复印件,'+
' wbsm as 五笔首码,wbcm as 五笔全码,'+
' pysm as 拼音首码,pycm as 拼音全码 '+
' from ywryda order by 单位编码';
ADOQuery1.Open;
end;
procedure show_ywryda_print;//这是我写的接口函数
var
frm_ywryda_print: Tfrm_ywryda_print;
begin
if frm_ywryda_print=nil then
frm_ywryda_print := tfrm_ywryda_print.Create(application);
frm_ywryda_print.InitData;
frm_ywryda_print.Preview;
end;
end.
主窗体中的调用方法:
procedure Tfrm_ywryda.ToolButton6Click(Sender: TObject);
begin
show_ywryda_print;
end;
打印单元的源代码:
unit Unit_ywryda_print;
interface
uses Windows, SysUtils, Messages, Classes, Graphics, Controls,
StdCtrls, ExtCtrls, Forms, QuickRpt, QRCtrls, DB, ADODB;
type
Tfrm_ywryda_print = class(TQuickRep)
PageHeaderBand1: TQRBand;
QRLabel1: TQRLabel;
DetailBand1: TQRBand;
QRDBText3: TQRDBText;
QRShape8: TQRShape;
QRDBText1: TQRDBText;
QRDBText5: TQRDBText;
QRDBText4: TQRDBText;
QRDBText6: TQRDBText;
QRDBText7: TQRDBText;
QRShape12: TQRShape;
QRShape14: TQRShape;
QRShape15: TQRShape;
QRShape16: TQRShape;
ColumnHeaderBand1: TQRBand;
QRLabel2: TQRLabel;
QRLabel8: TQRLabel;
QRLabel7: TQRLabel;
QRLabel4: TQRLabel;
QRLabel5: TQRLabel;
QRLabel6: TQRLabel;
QRShape1: TQRShape;
QRShape3: TQRShape;
QRShape5: TQRShape;
QRShape6: TQRShape;
QRShape7: TQRShape;
ADOQuery1: TADOQuery;
procedure InitData;
private
public
end;
var
frm_ywryda_print: Tfrm_ywryda_print;
procedure show_ywryda_print;
implementation
{$R *.DFM}
{ Tfrm_ywryda_print }
function adoconnect_dl:TADOConnection;external 'ADOConnectionpubLib.dll' name 'adoconnect_dl';
procedure Tfrm_ywryda_print.InitData;
begin
ADOQuery1.Connection:=adoconnect_dl;
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:='select rydah as 人员档案号,dwbm as 单位编码,dwmc as 单位名称,'+
' xm as 姓名,sfzh as 身份证号,'+
' xb as 性别,wtsnx as 委托书年限,wtsfw as 委托书范围,'+
' sfyfrdbwtsyj as 是否有法人代表委托书原件,'+
' sfyxsrysfzfyj as 是否有销售人员身份证复印件,'+
' wbsm as 五笔首码,wbcm as 五笔全码,'+
' pysm as 拼音首码,pycm as 拼音全码 '+
' from ywryda order by 单位编码';
ADOQuery1.Open;
end;
procedure show_ywryda_print;//这是我写的接口函数
var
frm_ywryda_print: Tfrm_ywryda_print;
begin
if frm_ywryda_print=nil then
frm_ywryda_print := tfrm_ywryda_print.Create(application);
frm_ywryda_print.InitData;
frm_ywryda_print.Preview;
end;
end.
主窗体中的调用方法:
procedure Tfrm_ywryda.ToolButton6Click(Sender: TObject);
begin
show_ywryda_print;
end;