动态库问题(100分)

  • 主题发起人 主题发起人 永不言败2
  • 开始时间 开始时间

永不言败2

Unregistered / Unconfirmed
GUEST, unregistred user!
主程序如下:Form100的formStyle=fsMDIForm
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls, Menus;
type
TForm100 = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure FormClose(Sender: TObject
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form100: TForm100;
implementation
{$R *.DFM}
function ShowMyForms(App:TApplication;MyParent:TForm):integer;stdcall;External'mydll.dll';
procedure TForm100.N2Click(Sender: TObject);
begin
ShowMyForms(Application,Self);
end;
procedure TForm100.N3Click(Sender: TObject);
begin
Close;
end;
procedure TForm100.FormClose(Sender: TObject
var Action: TCloseAction);
begin
Action:=caFree;
end;
end.

动态库如下:
unit Unit1;Form1的formstyle=fsMDIChild
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;
function ShowMyForms(App:TApplication;MyParent:Tform):integer;stdcall;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject
var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1:TForm1;
implementation
{$R *.DFM}
function ShowMyForms(App:TApplication;MyParent:Tform):integer;stdcall;
var
afrm:Tform1;
begin
Result:=1;
Application:=App;
Try
afrm:=TForm1.Create(MyParent);
afrm.Show;
except
Result:=-1;
end;
end;
procedure TForm1.FormClose(Sender: TObject
var Action: TCloseAction);
begin
Action:=caFree;
form1.Free;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
form1.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage('hell0');
end;
end.

调用时没问题,但是关闭主程序时总是报错,请高手指点。
各位兄台,小弟迫切需要解决这个问题,请各位把源码Copy下去好好调试一下。先谢了,
请大家行行好,帮个忙。
 
程序几乎不可用,我测试过,
给个箱子,发段代码 骗你得分。
 
不能这样,最好参考别人的例子
 

Similar threads

I
回复
0
查看
578
import
I
I
回复
0
查看
540
import
I
I
回复
0
查看
724
import
I
I
回复
0
查看
789
import
I
I
回复
0
查看
775
import
I
后退
顶部