看看吧:
dll:
library dldf;
uses
SysUtils,
Classes,
forms,
windows,
dllformInput in '../继承表单/dllformInput.pas' {dllFormInputForm},
dllformInPanel in '../继承表单/dllformInPanel.pas' {dllformInPanelForm},
quceList in 'quceList.pas' {quceListForm},
dm in 'dm.pas' {clientdm: TDataModule},
resourcestringunit in '../resourcestringunit.pas',
dllformInPanelSecondUnit in '../继承表单/dllformInPanelSecondUnit.pas' {dllformInPanelSecondForm},
zichangguanliunit in 'zichangguanliunit.pas' {zichanGuanliForm},
biandianzhanUnit in 'biandianzhanUnit.pas' {biandianzhanForm},
{$R *.res}
var
DLLApp: TApplication;
procedure DLLUnloadProc(Reason : Integer);
begin
if Reason = DLL_PROCESS_DETACH then Application := DLLApp;//恢复
end;
exports
initdldf,
getquceListForm,
getzichanGuanliForm;
begin
DLLApp := Application; //保存 DLL 中初始的 Application 对象
DLLProc := @DLLUnloadProc; //保证 DLL 卸载时恢复原来的 Application
end.
initdldf 在dm中
procedure initdldf(AConnection: TADOConnection;app:TApplication); stdcall;
var
i:integer;
begin
application := app;
clientdm := tClientdm.Create(nil);
for i:=0 to clientdm.componentcount-1 do
begin
if clientdm.components is TCustomADODataSet then
(clientdm.components as TCustomADODataSet).connection:=AConnection;
end;
end;
getquceListForm在dll窗口中:
function getzichanGuanliForm:TForm ;StdCall;
begin
// if quceListForm = nil then
begin
zichanGuanliForm := tzichanGuanliForm.Create(nil);
end;
result := zichanGuanliForm;
end;
应用程序调用:
initdldf(adoconnection1,application);
currentPanelform := getzichanGuanliForm;
windows.SetParent(currentPanelform.Handle,panel1.Handle);
currentPanelform.Show;
请看看是什么问题。