dll窗体设成主程序的子窗体
主程序form1设为fsMDIForm,然后调用dll中的窗体(fsMDIChild),并设成主程序的子窗体,不成功,请教各位高手了...谢谢.
主程序:
private
dl_xm,dl_qx,joinstr:string;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
kc_handle:THandle;
implementation
{$R *.dfm}
procedure TForm1.FormResize(Sender: TObject);
begin
Image1.Left:=(form1.Panel1.Width-form1.Image1.Width) div 2;
Image1.Top:=(form1.Panel1.Height-image1.Height) div 2;
end;
procedure TForm1.N5Click(Sender: TObject);
var
kc:procedure(dl_xm,joinstr,dl_qx:string);stdcall;
begin
kc_handle:=LoadLibrary(PChar('kcsh_dll.dll'));
if kc_handle<=0 then
begin
Application.MessageBox('动态库不存在!','提示',64);
exit;
end
else
begin
try
@kc:=GetProcAddress(kc_handle,'kc_tj');
kc(Form1.dl_xm,Form1.joinstr,form1.dl_qx);
except
Application.MessageBox('动态库加载失败!','提示',64);
exit;
end;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
dl_xm:='123';
dl_qx:='234';
joinstr:='345';
end;
end.
dll如下:
type
Tkcsh_tj = class(TForm)
private
dl_xm,joinstr,dl_qx:string;
{ Private declarations }
public
{ Public declarations }
end;
var
kcsh_tj:Tkcsh_tj;
procedure kc_create;
procedure kc_free;
procedure kc_tj(dl_xm:string;joinstr:string;dl_qx:string);stdcall;
implementation
{$R *.dfm}
procedure kc_create;
begin
kcsh_tj:=Tkcsh_tj.Create(Application.MainForm);
end;
procedure kc_free;
begin
if Assigned(kcsh_tj) then kcsh_tj.Free;
end;
procedure kc_tj(dl_xm,joinstr,dl_qx:string);stdcall;
begin
try
kc_create;
kcsh_tj.dl_xm:=dl_xm;
kcsh_tj.joinstr:=joinstr;
kcsh_tj.dl_qx:=dl_qx;
kcsh_tj.Show;
finally
kc_free;
end;
end;
end.