Y
Yujx
Unregistered / Unconfirmed
GUEST, unregistred user!
把QuickRep封装到Dll中,在传送数据时总出现错误;在不传送数据时不会出现错误,
错误内容是地址出错之类,请各位帮忙
此问题的代码如下:
DLL端:///////////////
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, QuickRpt, Qrctrls, Grids, DBGrids, Db, ADODB, PRINTERS,
QRPrntr, StdCtrls, Mask, DBTables;
type
TForm3 = class(TForm)
QuickRep1: TQuickRep;
QRBand1: TQRBand;
QRLTitle: TQRLabel;
QRBTitle: TQRBand;
QRBColumn: TQRBand;
QRBDetail: TQRBand;
QRBSummary: TQRBand;
QRBand6: TQRBand;
Table1: TTable;
QRLabel1: TQRLabel;
QRDBText1: TQRDBText;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
Procedure PrintForm(Table : TTable);
stdcall;
implementation
{$R *.DFM}
Procedure PrintForm(Table : TTable);
stdcall;
begin
try
Form3 := TForm3.Create(Application);
Form3.QuickRep1.DataSet := Table;
Form3.QRDBText1.DataSet := Table;
Form3.QRDBText1.DataField := Table.Fields[0].FieldName;
Form3.QuickRep1.PreviewModal;
Finally
Form3.QuickRep1.Free;
Form3.Free;
Form3 := nil;
end;
end;
end.
///////////////////////
应用程序调用端:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls, ExtCtrls, StdCtrls, Buttons, Db, DBTables, Grids,
DBGrids, Mask, DBCtrls;
type
PrintSet = record
sCapion : String;
iTop : Integer;
iLeft : Integer;
CancelFlag : Boolean;
end;
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Table1: TTable;
DataSource1: TDataSource;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Table1Name: TStringField;
Table1Capital: TStringField;
Table1Continent: TStringField;
Table1Area: TFloatField;
Table1Population: TFloatField;
Label1: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Label3: TLabel;
DBEdit3: TDBEdit;
Label4: TLabel;
DBEdit4: TDBEdit;
Label5: TLabel;
DBEdit5: TDBEdit;
Panel1: TPanel;
procedure BitBtn1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
Procedure PrintForm(Table : TTable);
stdcall;
external 'Printdll.dll';
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
PrintForm(Table1);
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
Table1.Open;
end;
procedure TForm1.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
Table1.Close;
end;
end.
错误内容是地址出错之类,请各位帮忙
此问题的代码如下:
DLL端:///////////////
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, QuickRpt, Qrctrls, Grids, DBGrids, Db, ADODB, PRINTERS,
QRPrntr, StdCtrls, Mask, DBTables;
type
TForm3 = class(TForm)
QuickRep1: TQuickRep;
QRBand1: TQRBand;
QRLTitle: TQRLabel;
QRBTitle: TQRBand;
QRBColumn: TQRBand;
QRBDetail: TQRBand;
QRBSummary: TQRBand;
QRBand6: TQRBand;
Table1: TTable;
QRLabel1: TQRLabel;
QRDBText1: TQRDBText;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
Procedure PrintForm(Table : TTable);
stdcall;
implementation
{$R *.DFM}
Procedure PrintForm(Table : TTable);
stdcall;
begin
try
Form3 := TForm3.Create(Application);
Form3.QuickRep1.DataSet := Table;
Form3.QRDBText1.DataSet := Table;
Form3.QRDBText1.DataField := Table.Fields[0].FieldName;
Form3.QuickRep1.PreviewModal;
Finally
Form3.QuickRep1.Free;
Form3.Free;
Form3 := nil;
end;
end;
end.
///////////////////////
应用程序调用端:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
QuickRpt, Qrctrls, ExtCtrls, StdCtrls, Buttons, Db, DBTables, Grids,
DBGrids, Mask, DBCtrls;
type
PrintSet = record
sCapion : String;
iTop : Integer;
iLeft : Integer;
CancelFlag : Boolean;
end;
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Table1: TTable;
DataSource1: TDataSource;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Table1Name: TStringField;
Table1Capital: TStringField;
Table1Continent: TStringField;
Table1Area: TFloatField;
Table1Population: TFloatField;
Label1: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Label3: TLabel;
DBEdit3: TDBEdit;
Label4: TLabel;
DBEdit4: TDBEdit;
Label5: TLabel;
DBEdit5: TDBEdit;
Panel1: TPanel;
procedure BitBtn1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
Procedure PrintForm(Table : TTable);
stdcall;
external 'Printdll.dll';
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
PrintForm(Table1);
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
Table1.Open;
end;
procedure TForm1.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
Table1.Close;
end;
end.