5 个解决方案
#1
ding
#2
主窗體有沒有傳遞什麼進入子窗體???
#3
var
FormHandle:hwnd;
dllapp:tapplication;
procedure LoadsysreportDLL(PApplication:TApplication;PForm: TForm;FormName:shortString;MainHandle:integer;datamodule:Tfrm_dm;pdepartment:shortstring); export; stdcall;
begin
Application:=PApplication;
// Screen := Scr;
FormHandle:=MainHandle;
frm_dm:=datamodule;
depment:=pdepartment;
if FormName='frm_count' then
begin
if not Assigned(frm_count) then
frm_count:= Tfrm_count.Create(PForm);
end;
if FormName='frm_order' then
begin
if not Assigned(frm_order) then
frm_order:=Tfrm_order.Create(PForm);
end;
if FormName='frm_plantp' then
begin
if not Assigned(frm_plantp) then
frm_plantp:=Tfrm_plantp.Create(PForm);
end;
if FormName='frm_time' then
begin
if not Assigned(frm_time) then
frm_time:= Tfrm_time.Create(PForm);
end;
end;
procedure DLLUnloadProc(Reason:Integer);register;
begin
if (Reason=DLL_PROCESS_DETACH) or (Reason=DLL_THREAD_DETACH) then
begin
if assigned(frm_count) then
frm_count.Free;
if assigned(frm_order) then
frm_order.Free;
if assigned(frm_plantp) then
frm_plantp.Free;
if assigned(frm_time) then
frm_time.Free;
Application:=DllApp;
CoUnInitialize;
end;
end;
exports LoadsysreportDLL;
begin
DllApp:= Application;
CoInitialize(nil);
DLLProc := @DLLUnloadProc;
end.
FormHandle:hwnd;
dllapp:tapplication;
procedure LoadsysreportDLL(PApplication:TApplication;PForm: TForm;FormName:shortString;MainHandle:integer;datamodule:Tfrm_dm;pdepartment:shortstring); export; stdcall;
begin
Application:=PApplication;
// Screen := Scr;
FormHandle:=MainHandle;
frm_dm:=datamodule;
depment:=pdepartment;
if FormName='frm_count' then
begin
if not Assigned(frm_count) then
frm_count:= Tfrm_count.Create(PForm);
end;
if FormName='frm_order' then
begin
if not Assigned(frm_order) then
frm_order:=Tfrm_order.Create(PForm);
end;
if FormName='frm_plantp' then
begin
if not Assigned(frm_plantp) then
frm_plantp:=Tfrm_plantp.Create(PForm);
end;
if FormName='frm_time' then
begin
if not Assigned(frm_time) then
frm_time:= Tfrm_time.Create(PForm);
end;
end;
procedure DLLUnloadProc(Reason:Integer);register;
begin
if (Reason=DLL_PROCESS_DETACH) or (Reason=DLL_THREAD_DETACH) then
begin
if assigned(frm_count) then
frm_count.Free;
if assigned(frm_order) then
frm_order.Free;
if assigned(frm_plantp) then
frm_plantp.Free;
if assigned(frm_time) then
frm_time.Free;
Application:=DllApp;
CoUnInitialize;
end;
end;
exports LoadsysreportDLL;
begin
DllApp:= Application;
CoInitialize(nil);
DLLProc := @DLLUnloadProc;
end.
#4
DLL 中DATAMODULE是直接引用主程序中的DATAMODULE,传递frm_dm对象。
#5
自己发现是多线程问题,关掉就OK了
#1
ding
#2
主窗體有沒有傳遞什麼進入子窗體???
#3
var
FormHandle:hwnd;
dllapp:tapplication;
procedure LoadsysreportDLL(PApplication:TApplication;PForm: TForm;FormName:shortString;MainHandle:integer;datamodule:Tfrm_dm;pdepartment:shortstring); export; stdcall;
begin
Application:=PApplication;
// Screen := Scr;
FormHandle:=MainHandle;
frm_dm:=datamodule;
depment:=pdepartment;
if FormName='frm_count' then
begin
if not Assigned(frm_count) then
frm_count:= Tfrm_count.Create(PForm);
end;
if FormName='frm_order' then
begin
if not Assigned(frm_order) then
frm_order:=Tfrm_order.Create(PForm);
end;
if FormName='frm_plantp' then
begin
if not Assigned(frm_plantp) then
frm_plantp:=Tfrm_plantp.Create(PForm);
end;
if FormName='frm_time' then
begin
if not Assigned(frm_time) then
frm_time:= Tfrm_time.Create(PForm);
end;
end;
procedure DLLUnloadProc(Reason:Integer);register;
begin
if (Reason=DLL_PROCESS_DETACH) or (Reason=DLL_THREAD_DETACH) then
begin
if assigned(frm_count) then
frm_count.Free;
if assigned(frm_order) then
frm_order.Free;
if assigned(frm_plantp) then
frm_plantp.Free;
if assigned(frm_time) then
frm_time.Free;
Application:=DllApp;
CoUnInitialize;
end;
end;
exports LoadsysreportDLL;
begin
DllApp:= Application;
CoInitialize(nil);
DLLProc := @DLLUnloadProc;
end.
FormHandle:hwnd;
dllapp:tapplication;
procedure LoadsysreportDLL(PApplication:TApplication;PForm: TForm;FormName:shortString;MainHandle:integer;datamodule:Tfrm_dm;pdepartment:shortstring); export; stdcall;
begin
Application:=PApplication;
// Screen := Scr;
FormHandle:=MainHandle;
frm_dm:=datamodule;
depment:=pdepartment;
if FormName='frm_count' then
begin
if not Assigned(frm_count) then
frm_count:= Tfrm_count.Create(PForm);
end;
if FormName='frm_order' then
begin
if not Assigned(frm_order) then
frm_order:=Tfrm_order.Create(PForm);
end;
if FormName='frm_plantp' then
begin
if not Assigned(frm_plantp) then
frm_plantp:=Tfrm_plantp.Create(PForm);
end;
if FormName='frm_time' then
begin
if not Assigned(frm_time) then
frm_time:= Tfrm_time.Create(PForm);
end;
end;
procedure DLLUnloadProc(Reason:Integer);register;
begin
if (Reason=DLL_PROCESS_DETACH) or (Reason=DLL_THREAD_DETACH) then
begin
if assigned(frm_count) then
frm_count.Free;
if assigned(frm_order) then
frm_order.Free;
if assigned(frm_plantp) then
frm_plantp.Free;
if assigned(frm_time) then
frm_time.Free;
Application:=DllApp;
CoUnInitialize;
end;
end;
exports LoadsysreportDLL;
begin
DllApp:= Application;
CoInitialize(nil);
DLLProc := @DLLUnloadProc;
end.
#4
DLL 中DATAMODULE是直接引用主程序中的DATAMODULE,传递frm_dm对象。
#5
自己发现是多线程问题,关掉就OK了