<OBJECT ID="PhotoUpload" CLASSID="CLSID:DE3496D2-AFB9-47EB-A8C2-C3B330222513" Name="photoupload" codebase="http://www.photo.163.com/PhotoUpload.cab#version=1,0,4,0">
<param name="seqid" value="username=kuxiku123&isvip=0&filedistribution=6&key=83a14c4f415584cbfd6e754b2d921f3e&directoryid=8621327">
<param name="PhotoSpace" VALUE="10240000">
</OBJECT>
<param name="seqid" value="username=kuxiku123&isvip=0&filedistribution=6&key=83a14c4f415584cbfd6e754b2d921f3e&directoryid=8621327">
<param name="PhotoSpace" VALUE="10240000">
</OBJECT>
将新添加的Property改为 PhotoSpace, delphi会自动添加Get_PhotoSpace和Set_PhotoSpace
两个函数, 调运Get_PhotoSpace应该就能取得 param的值
你试一下,应该可以 ^_^
<OBJECT style="display:none "
classid="clsid:4BBF9074-8799-41D9-B4E8-BF93C4372E6B"
codebase="./PrintBarcodeProj1.inf"
width=117
height=47
align=center
hspace=0
vspace=0
>
<param name="BarcodeStr" value="<%=sendstr%>">
</OBJECT>红色这行..就是要从Html要传入ocx的参数。而在Delphi中的ActiveX Form中点选 View->Type Library,然后点选有个像红色棒棒糖的Interface然后点鼠标右键,New一个新的property,如图一。
帮新的property去个名字,及数据型态,此property即为你要从Html传进来的参数。取好名字之后Delphi会自动将Get和Put两个Property设为同一名字,如下图二。
新增完之后记得按下Type Library中里那一排工具列里面的Refresh。按下之后,在ActiveX form的程序代码就会多出两个函式,如下:function Get_BarcodeStr: WideString; safecall;
procedure Set_BarcodeStr(const Value: WideString); safecall;
在这两个函式里面,要加上下面的程序代码,当然也可以加入一些你自己需要的程序。function TActiveXForm1.Get_BarcodeStr: WideString;
begin
Result := WideString(BarcodeStr);
end;procedure TActiveXForm1.Set_BarcodeStr(const Value: WideString);
begin
BarcodeStr := Value;
end;
之后,就可以在你自己写的其它函式里面用的这个从Html传进来的参数了,用法如下:
例如我在Timer里面用道:
procedure TActiveXForm1.Timer1Timer(Sender: TObject);
var str:String;
begin
Timer1.Enabled:=False;
str := get_BarcodeStr;
if (length(str) = 0) then
exit
else
showmessage(str);
end;
将这个form包成ocx,Deploy之后,在Html语法记得加上文章最上面的那行
<param name="BarcodeStr" value="<%=sendstr%>">
这样这个网页就能将参数传进这个ocx了!!不好意思,沒有说清楚。
还要在多宣告一个变数,例如我宣告在Private中:type
TActiveFormX = class(TActiveForm, IActiveFormX)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
BarCodeStr:WideString;
{ Private declarations }
FEvents: IActiveFormXEvents;
procedure ActivateEvent(Sender: TObject);
procedure ClickEvent(Sender: TObject);
procedure CreateEvent(Sender: TObject);这样Complie就可以了...
二、菜单"View"-->"Type Library",右击"IAFXComNgUpdate"-->"New"-->"Property"新建一属性,并将该属性重命名为"iaswsdl",Type属性改为"BSTR"(或WideString)。按同样办法,新建一个字符串型属性"TableName"。
三、查看AFXComNgUpdateImpl1.pas单元,可看到以下代码:
function TAFXComNgUpdate.Get_iaswsdl: WideString;
beginend;procedure TAFXComNgUpdate.Set_iaswsdl(const Value: WideString);
beginend;function TAFXComNgUpdate.Get_TableName: WideString;
beginend;procedure TAFXComNgUpdate.Set_TableName(const Value: WideString);
beginend;
四、定义全局变量
var
MyCount:integer;
iaswsdl,TableName:string;
五、在AFXComNgUpdate的OnCreate事件初始化MyCount为0:
procedure TAFXComNgUpdate.ActiveFormCreate(Sender: TObject);
begin
MyCount:=0;
end;
六、添加一个全局过程:
procedure TAFXComNgUpdate.DoMyApplication;
begin
inc(MyCount);
Showmessage(Format('MyCount=%d,iaswsdl=%s,TableName:=%s',[MyCount,iaswsdl,TableName]));
if MyCount=2 then ;//已接收到2个参数,可转入你自己定义的功能
end;
七、修改过程如下:
procedure TAFXComNgUpdate.Set_iaswsdl(const Value: WideString);
begin //此Value的值来自网页参数,得及时把它传给全局变量
iaswsdl:=Value;//<param name="iaswsdl" value="http://10.79.1.168:7777/blob-tys-context-root/mypackage2.testblob">
DoMyApplication;
end;procedure TAFXComNgUpdate.Set_TableName(const Value: WideString);
begin //此Value的值来自网页参数,得及时把它传给全局变量
TableName:=Value;//<param name="TableName" value="OSIS_FWCL_B_FJ">
DoMyApplication;
end;
八、编译、发布网页AFXComNgUpdateProj1.htm,并修改网页内容如下:
<HTML>
<H1> Delphi 6 ActiveX Test Page </H1><p>
You should see your Delphi 6 forms or controls embedded in the form below.
<HR><center><P>
<OBJECT
classid="clsid:67D18AB3-3B9B-40F8-993E-FB3B0DD0D276"
codebase="AFXComNgUpdateProj1.ocx#version=1,0,0,0"
width=252
height=142
align=center
hspace=0
vspace=0
>
<param name="iaswsdl" value="http://10.79.1.168:7777/blob-tys-context-root/mypackage2.testblob">
<param name="TableName" value="OSIS_FWCL_B_FJ">
</OBJECT>
</HTML>
九、执行网页AFXComNgUpdateProj1.htm,成功!