fastreport问题 ( 积分: 50 )

  • 主题发起人 主题发起人 xingkong97
  • 开始时间 开始时间
X

xingkong97

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟在的报表是做在了dll中,可是在dll中小弟无法设置fastreport的数据库选项,请问在dll中做fastreport报表该如何做啊?
 
把 ADOConnection 的指针传给 DLL,就可以设置了。
 
zywcd&nbsp;(2006-09-06&nbsp;23:06:31)&nbsp;&nbsp;<br>今天测试通过的代码。<br>贴出来。<br>-------------------------------------------------<br>unit&nbsp;TestDLL;<br><br>interface<br><br>uses<br>&nbsp;SysUtils,Windows,Messages,Classes,Graphics,Controls,<br>&nbsp;Forms,Dialogs,StdCtrls,DB,ExtCtrls,DBTables;<br><br>type<br>&nbsp;TShowForm=function(mainform:Tform):Tform;&nbsp;StdCall;<br>&nbsp;tdllFormClose=procedure(tt:LongInt);&nbsp;StdCall;<br><br>&nbsp;EDLLLoadError=class(Exception);<br><br>&nbsp;TfrmCallDLL=class(Tform)<br>&nbsp;&nbsp;&nbsp;Database1:TDatabase;<br>&nbsp;&nbsp;&nbsp;btnCallDLL:TButton;<br>&nbsp;&nbsp;&nbsp;btnClose:TButton;<br>&nbsp;&nbsp;&nbsp;procedure&nbsp;btnCallDLLClick(Sender:TObject);<br>&nbsp;&nbsp;&nbsp;procedure&nbsp;btnCloseClick(Sender:TObject);<br>&nbsp;&nbsp;&nbsp;procedure&nbsp;FormClose(Sender:TObject;&nbsp;var&nbsp;Action:TCloseAction);<br>&nbsp;end;<br><br>var<br>&nbsp;frmCallDLL:TfrmCallDLL;<br><br>implementation<br><br>var<br>&nbsp;LibHandle:THandle;<br>&nbsp;ShowForm:TShowForm;<br>&nbsp;dllFormClose:tdllFormClose;<br>&nbsp;dllform:Tform;<br>{$R&nbsp;*.DFM}<br><br>procedure&nbsp;TfrmCallDLL.btnCallDLLClick(Sender:TObject);<br>begin<br>&nbsp;LibHandle:=LoadLibrary('RptDLL.DLL');<br>&nbsp;try<br>&nbsp;&nbsp;&nbsp;if&nbsp;LibHandle=HINSTANCE_ERROR&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raise&nbsp;EDLLLoadError.Create('Unable&nbsp;to&nbsp;Load&nbsp;DLL');<br>&nbsp;&nbsp;&nbsp;@ShowForm:=GetProcAddress(LibHandle,'ShowForm');<br>&nbsp;&nbsp;&nbsp;@dllFormClose:=GetProcAddress(LibHandle,'FormClose');<br>&nbsp;&nbsp;&nbsp;if&nbsp;not(@ShowForm=nil)&nbsp;then&nbsp;dllform:=ShowForm(frmCallDLL);<br>&nbsp;except<br>&nbsp;&nbsp;&nbsp;;<br>&nbsp;end;<br>end;<br><br>procedure&nbsp;TfrmCallDLL.btnCloseClick(Sender:TObject);<br>begin<br>//&nbsp;&nbsp;Close;<br>end;<br><br>procedure&nbsp;TfrmCallDLL.FormClose(Sender:TObject;&nbsp;var&nbsp;Action:TCloseAction);<br>begin<br>&nbsp;dllform.Release;<br>//if&nbsp;LibHandle&lt;&gt;0&nbsp;then&nbsp;FreeLibrary(LibHandle);<br>end;<br><br>end.<br><br><br>---------------------------------------<br><br>unit&nbsp;FormDLL;<br><br>interface<br><br>uses<br>&nbsp;SysUtils,Windows,Messages,Classes,Graphics,Controls,<br>&nbsp;Forms,Dialogs,StdCtrls,&nbsp;frxDesgn,&nbsp;frxClass;&nbsp;//,frxDBSet,frxClass;<br><br>type<br>&nbsp;TfrmDLL=class(TForm)<br>&nbsp;&nbsp;&nbsp;btnBioLifePrintPreview:TButton;<br>&nbsp;&nbsp;&nbsp;frxReport1:&nbsp;TfrxReport;<br>&nbsp;&nbsp;&nbsp;frxDesigner1:&nbsp;TfrxDesigner;<br>&nbsp;&nbsp;&nbsp;procedure&nbsp;btnBioLifePrintPreviewClick(Sender:TObject);<br>&nbsp;private<br>&nbsp;&nbsp;&nbsp;{&nbsp;Private&nbsp;declarations&nbsp;}<br>&nbsp;public<br>&nbsp;&nbsp;&nbsp;{&nbsp;Public&nbsp;declarations&nbsp;}<br>&nbsp;end;<br><br>function&nbsp;ShowForm(mainform:TForm):TForm;&nbsp;StdCall;<br>procedure&nbsp;FormClose(AFormRef:LongInt);&nbsp;StdCall;<br><br>implementation<br><br>{$R&nbsp;*.DFM}<br><br>{------------------------------------------------------------------------}<br>function&nbsp;ShowForm(mainForm:TForm):TForm;stdcall<br>var<br>&nbsp;Form1:&nbsp;TfrmDLL;<br>&nbsp;ptr:PLongInt;<br>begin<br>&nbsp;ptr:=@(Application.MainForm);<br>&nbsp;ptr^:=LongInt(mainForm);<br>&nbsp;Form1:=TfrmDLL.Create(mainForm);<br>&nbsp;Form1.Show;//&nbsp;.Show;<br>//&nbsp;&nbsp;Form1.<br>&nbsp;result:=Form1;<br><br>end;<br>procedure&nbsp;TfrmDLL.btnBioLifePrintPreviewClick(Sender:TObject);<br>begin<br>&nbsp;&nbsp;&nbsp;frxReport1.ShowReport;<br>end;<br><br>procedure&nbsp;FormClose(AFormRef:LongInt);<br>begin<br>&nbsp;if&nbsp;AFormRef&gt;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;TfrmDLL(AFormRef).Release;<br>end;<br><br>end.
 
多人接受答案了。
 
后退
顶部