我将子窗体封装到DLL中,调用及使用当前都没什么问题
后来将fastreport放到DLL中的窗体中,在调用fastreport时出错。
跟踪到是fastreport在创建窗体时出错
FPreviewForm := TfrxPreviewForm.Create(Application);请帮忙看如何解决?谢谢先。
后来将fastreport放到DLL中的窗体中,在调用fastreport时出错。
跟踪到是fastreport在创建窗体时出错
FPreviewForm := TfrxPreviewForm.Create(Application);请帮忙看如何解决?谢谢先。
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, DBTables, DB, frxDBSet, frxClass;type
TfrmDLL = class(TForm)
btnBioLifePrintPreview: TButton;
Table1: TTable;
frxDBDataset1: TfrxDBDataset;
frxReport1: TfrxReport;
procedure btnBioLifePrintPreviewClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
function ShowForm(A: TApplication): Bool; StdCall;
implementation{$R *.DFM}{------------------------------------------------------------------------}function ShowForm(A: TApplication): Bool;
var
Form1: TfrmDLL;
begin
Application.Handle := A.Handle;
Form1 := TfrmDLL.Create(A);
try
Result := (Form1.ShowModal = mrOK);
finally
Form1.Free;
end;
end;procedure TfrmDLL.btnBioLifePrintPreviewClick(Sender: TObject);
begin
frxReport1.ShowReport;
end;procedure TfrmDLL.FormActivate(Sender: TObject);
begin
Session.Active := True;
end;procedure TfrmDLL.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Session.Active := False;
end;end.
unit TestDLL;interfaceuses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, DB, ExtCtrls, DBTables;type
TShowForm = function(A: TApplication): Bool; StdCall; EDLLLoadError = class(Exception); TfrmCallDLL = class(TForm)
Database1: TDatabase;
btnCallDLL: TButton;
btnClose: TButton;
procedure btnCallDLLClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
end;var
frmCallDLL: TfrmCallDLL;implementation
{$R *.DFM}procedure TfrmCallDLL.btnCallDLLClick(Sender: TObject);
var
LibHandle: THandle;
ShowForm: TShowForm;
begin
LibHandle := LoadLibrary('RptDLL.DLL');
try
if LibHandle = HINSTANCE_ERROR then
raise EDLLLoadError.Create('Unable to Load DLL');
@ShowForm := GetProcAddress(LibHandle, 'ShowForm');
if not (@ShowForm = nil) then
ShowForm(Application);
finally
FreeLibrary(LibHandle);
end;
end;procedure TfrmCallDLL.btnCloseClick(Sender: TObject);
begin
Close;
end;
end.
能具体些吗?我没太明白,麻烦你了