简单问题求解!!

xzhr 2001-08-01 10:08:37
小弟制作一窗体程序,将WinPro.dpr文件修改如下:
library WinPro;
uses
WinDll in 'WinDll.pas' {Form1};
exports ShowPassWindow;
{$R *.RES}

begin

end.
而WinDll.pas文件如下:
unit WinDll;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure ShowPassWindow(AHandle:THandle;ACaption:string);stdcall;
implementation
procedure ShowPassWindow(AHandle:THandle;ACaption:string);
var
DLLForm:TForm1;
begin
Application.Handle:=AHandle;
DLLForm.Create(Application);
DLLForm.Caption:=ACaption;
try
DLLForm.ShowModal;
finally
DLLForm.Free;
end;
end;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
end.

经保存得到WinPro.dll文件,退出,在一新程序中作如下处理:
声明:
procedure ShowPassWindow(AHandle:THandle;ACaption:string);stdcall;external 'winpro.dll';

在Button1的单击处理函数中代码如下
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowPassWindow(Application.Handle,'ok');
end;
运行程序:单击button1,出错
...全文
38 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
chechy 2001-08-01
  • 打赏
  • 举报
回复
DLLForm.Create(Application);
问题就在这句。应该是
DLLFORM := TForm1.Create(Application);


Application.Handle:=AHandle;这句没问题。
trainbox 2001-08-01
  • 打赏
  • 举报
回复
Application.Handle:=AHandle;(这句话有问题)

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧