H
hugo5590484
Unregistered / Unconfirmed
GUEST, unregistred user!
主程序中的调用DLL中窗体的方法
.......
procedure TForm1.single_btnClick(Sender: TObject);
var
DLLHandle: THandle;
DLLSub: InvokeTr1DLLForm;
begin
DLLHandle := LoadLibrary('dll/single.dll');
if DLLHandle <> 0 then
begin
@DLLSub := GetProcAddress(DLLHandle, 'OpenTr1_M');
if Assigned(DLLSub) then
begin
Tr1_Form := DLLSub(Application, Screen);
Tr1_form.Show;
hide;
end;
end;
//OpenTr1_M(Application,Screen).Show;
//OpenTr1_M(application.MainForm);
loadpictrue(sender);
end;
........
DLL工程中的主文件
..........
var
DLLApp: TApplication;
DLLScr: TScreen;
function OpenTr1_M(App: TApplication; Scr: TScreen):TForm;
var
ptrLongInt;
begin
Application := App;
Screen := Scr;
Application.CreateForm(TTr1_Mform, Tr1_Mform);
Application.CreateForm(TForm8, form8);
result:=Tr1_Mform;
end;
{procedure ShowCCC;stdcall;
begin
showmessage('调用DLL文件的测试');
end;}
procedure ExitDLL(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
begin
Application := DLLApp;
Screen := DLLScr;
end;
end;
exports
OpenTr1_M;
begin
DLLApp := Application;
DLLScr := Screen;
DLLProc := @ExitDLL;
end.
DLL工程中的FORM窗体
........
procedure TTr1_Mform.Label1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
label1.Color:=clred;
end;
procedure TTr1_Mform.Label1MouseLeave(Sender: TObject);
begin
label1.Color:=clgreen;
end;
......
当DLL调用时,显示窗体用SHOW方法时
方法如上Label1MouseMove这个有效果,但是Label1MouseLeave没有发生效果
如果非DLL调用,直接在程序中调用窗体则没有出现此种情况
方法如上Label1MouseMove,Label1MouseLeave都有效果
何种原因?请大虾们帮们解决一下,先谢过!急用!
.......
procedure TForm1.single_btnClick(Sender: TObject);
var
DLLHandle: THandle;
DLLSub: InvokeTr1DLLForm;
begin
DLLHandle := LoadLibrary('dll/single.dll');
if DLLHandle <> 0 then
begin
@DLLSub := GetProcAddress(DLLHandle, 'OpenTr1_M');
if Assigned(DLLSub) then
begin
Tr1_Form := DLLSub(Application, Screen);
Tr1_form.Show;
hide;
end;
end;
//OpenTr1_M(Application,Screen).Show;
//OpenTr1_M(application.MainForm);
loadpictrue(sender);
end;
........
DLL工程中的主文件
..........
var
DLLApp: TApplication;
DLLScr: TScreen;
function OpenTr1_M(App: TApplication; Scr: TScreen):TForm;
var
ptrLongInt;
begin
Application := App;
Screen := Scr;
Application.CreateForm(TTr1_Mform, Tr1_Mform);
Application.CreateForm(TForm8, form8);
result:=Tr1_Mform;
end;
{procedure ShowCCC;stdcall;
begin
showmessage('调用DLL文件的测试');
end;}
procedure ExitDLL(Reason: Integer);
begin
if Reason = DLL_PROCESS_DETACH then
begin
Application := DLLApp;
Screen := DLLScr;
end;
end;
exports
OpenTr1_M;
begin
DLLApp := Application;
DLLScr := Screen;
DLLProc := @ExitDLL;
end.
DLL工程中的FORM窗体
........
procedure TTr1_Mform.Label1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
label1.Color:=clred;
end;
procedure TTr1_Mform.Label1MouseLeave(Sender: TObject);
begin
label1.Color:=clgreen;
end;
......
当DLL调用时,显示窗体用SHOW方法时
方法如上Label1MouseMove这个有效果,但是Label1MouseLeave没有发生效果
如果非DLL调用,直接在程序中调用窗体则没有出现此种情况
方法如上Label1MouseMove,Label1MouseLeave都有效果
何种原因?请大虾们帮们解决一下,先谢过!急用!