这个问题之前我问过,可能是我没有说清楚问题,所以今天重新再发一贴.主调程序击"添加"调出DLL_1.DLL的添加窗体(FORM1,单元文件是sgdgd_tj.pas),添加完后击FORM1上"打印"钮打出来,这个打印个窗体FORM12(单元文件是SGDGD_TJDY.pas)上用QUICKREP控件做的打印(用到预览).
问题是我知道如何调用DLL中的添加窗体(FORM1,代码如下),不知如何调出打印用的FORM12.
DLL代码如下:
library dll_1;
uses
SysUtils,
ActiveX,
windows,
Classes,
sgdgd_tj in 'sgdgd_tj.pas' {Form1},
SGDGD_TJDY in 'SGDGD_TJDY.pas' {Form12};
procedure _DllProc(Reason: Integer);
begin
//DLL装载时调用CoInitialize
if Reason = DLL_PROCESS_ATTACH then
CoInitialize(nil)
else if Reason = DLL_PROCESS_DETACH then
//DLL卸载时调用CoUninitialize
CoUninitialize;
end;{$R *.res}
exports
myshowform1,
mycloseform1;
begin
DLLProc := @_DllProc;
_DllProc(DLL_PROCESS_ATTACH); //装载end.
sgdgd_tJ单元声明部份如下:public
{ Public declarations }
end;var
Form1: TForm1; function myshowform1(ahandle:thandle):longint;stdcall;
procedure mycloseform1(aformref:longint);stdcall;implementationuses Unit2, SGDGD_TJDY;{$R *.dfm}
function myshowform1(ahandle:thandle):longint;
var
form1:tform1;
begin
application.Handle:=ahandle;
form1:=tform1.Create(application);
form1.Show;
result:=longint(form1);
end; procedure mycloseform1(aformref:longint);
begin
if aformref>0 then
Tform1(aformref).free;
end;
sgdgd_tJDY单元部份要如何写就不知道了........主调程序如下:var
test: Ttest;
formref:longint;
function myshowform1(ahandle:thandle):longint;stdcall;
procedure mycloseform1(aformref:longint);stdcall;implementation
function myshowform1;external 'dll_1.dll';
procedure mycloseform1;external 'dll_1.dll';{$R *.dfm}procedure Ttest.Button1Click(Sender: TObject);
begin
formref:=myshowform1(application.handle);
//showmessage(inttostr(formref));end;procedure Ttest.Button2Click(Sender: TObject);
begin mycloseform1(formref);test.Close;end;
问题是我知道如何调用DLL中的添加窗体(FORM1,代码如下),不知如何调出打印用的FORM12.
DLL代码如下:
library dll_1;
uses
SysUtils,
ActiveX,
windows,
Classes,
sgdgd_tj in 'sgdgd_tj.pas' {Form1},
SGDGD_TJDY in 'SGDGD_TJDY.pas' {Form12};
procedure _DllProc(Reason: Integer);
begin
//DLL装载时调用CoInitialize
if Reason = DLL_PROCESS_ATTACH then
CoInitialize(nil)
else if Reason = DLL_PROCESS_DETACH then
//DLL卸载时调用CoUninitialize
CoUninitialize;
end;{$R *.res}
exports
myshowform1,
mycloseform1;
begin
DLLProc := @_DllProc;
_DllProc(DLL_PROCESS_ATTACH); //装载end.
sgdgd_tJ单元声明部份如下:public
{ Public declarations }
end;var
Form1: TForm1; function myshowform1(ahandle:thandle):longint;stdcall;
procedure mycloseform1(aformref:longint);stdcall;implementationuses Unit2, SGDGD_TJDY;{$R *.dfm}
function myshowform1(ahandle:thandle):longint;
var
form1:tform1;
begin
application.Handle:=ahandle;
form1:=tform1.Create(application);
form1.Show;
result:=longint(form1);
end; procedure mycloseform1(aformref:longint);
begin
if aformref>0 then
Tform1(aformref).free;
end;
sgdgd_tJDY单元部份要如何写就不知道了........主调程序如下:var
test: Ttest;
formref:longint;
function myshowform1(ahandle:thandle):longint;stdcall;
procedure mycloseform1(aformref:longint);stdcall;implementation
function myshowform1;external 'dll_1.dll';
procedure mycloseform1;external 'dll_1.dll';{$R *.dfm}procedure Ttest.Button1Click(Sender: TObject);
begin
formref:=myshowform1(application.handle);
//showmessage(inttostr(formref));end;procedure Ttest.Button2Click(Sender: TObject);
begin mycloseform1(formref);test.Close;end;
就是在调用DLL时,不知用如何把DLL中的FORM12窗本调出来呀.打印的代码都写好了,DLL用到的两个窗在没做成DLL之前测试过都是可以的,就是单元文件加入到DLL后,不知如何调出FORM12了(FORM1可以调出.FORM12就是在FORM1中的"打印"钮要用的打印预览呀.) .
sgdgd_tJDY;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;implementationprocedure TForm1.Button1Click(Sender: TObject);
var
form2 : TForm2;
begin
form2 := TForm2.Create(nil);
form2.ShowModal;
end;