Delphi 做ActiveX的详细过程

时间:2023-03-09 22:39:56
Delphi 做ActiveX的详细过程

1、新建

Delphi 做ActiveX的详细过程

如下图

Delphi 做ActiveX的详细过程

点击OK

Delphi 做ActiveX的详细过程

依然点击OK

Delphi 做ActiveX的详细过程

出现了如上图的节面,就像窗体一样。

然后 你就想干什么干什么。

这个做好之后,

这个是我设计的窗体。

Delphi 做ActiveX的详细过程

然后 就添加 外部可以调用的接口了。

如果你不想让外部调用 就 可以直接像平时用Delphi一样,该干什么干什么。

代码
procedure Set_SnapBuffer(Value: Integer); safecall;
procedure Set_Visible(Value: WordBool); safecall;
procedure MessageShow(Value:WideString);safecall;{这个是我自己添加的}
public
{ Public declarations }
procedure Initialize; override;
end;

implementation

然后在下面 写上

 procedure TActiveFormX.MessageShow(value:WideString);
 begin
Application.MessageBox(PChar(edit1.Text), '提示', MB_OK);
 end;

以上过程就把 接口写完了。接下来,配置环境然后来调试。

Delphi 做ActiveX的详细过程

出现如下节面

Delphi 做ActiveX的详细过程

然后如下填写

Delphi 做ActiveX的详细过程

点击OK

Delphi 做ActiveX的详细过程

如果你的代码没有写错 就直接通过了

然后

Delphi 做ActiveX的详细过程

设置启动参数

Delphi 做ActiveX的详细过程

就可以运行了。

Delphi 做ActiveX的详细过程

当然是允许了。

然后就出现

Delphi 做ActiveX的详细过程

这个时候 你就要修改html代码了

<HTML>
<H1> Delphi 7 ActiveX Test Page </H1><p>
You should see your Delphi 7 forms or controls embedded in the form below.
<HR><center><P>
<OBJECT
classid="clsid:C4BB6130-AE39-4EDB-98E1-BBAC3089496D"
codebase="http://localhost/ActiveFormProj1.ocx#version=1,0,0,0"
width=350
height=250
align=center
hspace=0
vspace=0
ID=jsShow//这个是我添加的
>
</OBJECT>
<script>
jsShow.MessageShow("");//本来不需要参数的,设计失误啊!
</script>
</HTML>