问个网页中使用OCX传参数的问题

jixiaoqiang 2006-10-23 03:25:53
随便写了一个activeform的Ocx,里面增加了一个myIP属性,然后打包发布,之后修改html文件,增加了
<param段等内容,现在发现网页加载后,param段设置的初始值好像不起作用,控件里面显示的值依旧是0,而用javascript写的倒是起作用,请问为什么param段不起作用??

说明:既然javascript的语句执行没有问题,说明ocx本身没有问题,属性已经暴露给外面了。

<HTML>
<H1> C++Builder 6 ActiveX Test Page </H1><p>
You should see your C++Builder 6 forms or controls embedded in the form below.
<HR><center><P>
<OBJECT
classid="clsid:74B351BD-427D-43F7-A406-319DAECBBE84"
codebase="http://JXQ-XGY/BaiChiProj1.inf"
id="baichi0"
width=650
height=450
align=center
hspace=0
vspace=0
>
<PARAM NAME="myIP" VALUE="100">

</OBJECT><br>
<input type="button" value="测试" onClick="javascript:document.all.baichi0.myIP=5;">
</HTML>
...全文
279 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jixiaoqiang 2006-10-24
  • 打赏
  • 举报
回复
请问CB中有相应的函数或者帮助吗?
jxm1985 2006-10-24
  • 打赏
  • 举报
回复
学习
jixiaoqiang 2006-10-23
  • 打赏
  • 举报
回复
再顶一次
jixiaoqiang 2006-10-23
  • 打赏
  • 举报
回复
onega写了一片文章,但是是关于vc的,不知道CB中怎样实现!

short answer: implement IPersistPropertyBag interface, long answer is given by others

I've been spending some time trying to figure out
how to code the "get custom property" from the value that
I put in the PARAM tag in my HTML page.
In fact it's really easy, the problem is that it was difficult to find
a easy sample talking about MFC implementation and not ATL.
SO...
1. Create you OLE Control using Active X wizard
2. Add a property using the GET/SET or the GlobalVariable
3. if on step 2 you created using the GET/SET , add a global variable
on your myolecontrolctl.cpp for example m_property
4. Modify by hand the PropExchange method of your control
using the PX_String, PX_Short, PX_....
depending of the type of variable you're using
you'll add the following
if your variable is a CString
void CActiveAdvCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
if (pPX->GetVersion() == (DWORD)MAKELONG(_wVerMinor, _wVerMajor))
{
PX_String(pPX,_T("myproperty"),m_property);
PX_String(pPX,_T("myproperty1"),m_property1);
}
}
where m_property is the variable and myproperty is the external name you gave
when you created the property.
So when calling the page from the browser, the PARAM will be loaded
to the different variables
<OBJECT CLASSID="clsid:1AEDB630-4A08-4C22-BC74-0629C264B2CA"
ALIGN="CENTER" WIDTH=100 HEIGHT=100 ID="DActiveX1">
<PARAM NAME="myproperty" VALUE="123">
<PARAM NAME="myproperty1" VALUE="555">
<PARAM NAME="Enabled" VALUE=1>
<PARAM NAME="_ExtentX" VALUE="0">
<PARAM NAME="_ExtentY" VALUE="0">
</OBJECT>
Hope this help
Anthony.
"Alexander Nickolov" <agnickolov@geocities.com> wrote in message news:<#4Ma63wmBHA.2084@tkmsftngp04>...
> Did you implement IPersistPropertyBag on your control?
> ============
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@geocities.com
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =========================
> ============
>
> "Anthony" <anthonyg@passinglane.com> wrote in message
> news:cff4bb7e.0201111456.7b620a25@posting.google.com...
> > Hi Everyone,
> >
> > I created an active X in VC6
> > Everything seems to work perfectly if I call my methods and properties
> > from a javascript.
> > BUT what ever I put in the PARAM tag are not initialized
> > my properties Get/Set are not called.. !
> >
> > Any idea or anything I'm doing wrong?
> >
> > Thanks for your help.
jixiaoqiang 2006-10-23
  • 打赏
  • 举报
回复
谢谢xxuu503
帖子又转到CB中来了,那么CB中如何实现象VC中的函数功能呢?
各位高人救命,待会另开贴送分.

xxuu503 2006-10-23
  • 打赏
  • 举报
回复
要自己读取的吧

VC6.0是

ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);

// TODO: Call PX_ functions for each persistent custom property.
PX_String(pPX,"URL",URL);


C++ builder不知道
jixiaoqiang 2006-10-23
  • 打赏
  • 举报
回复
顶一下
jixiaoqiang 2006-10-23
  • 打赏
  • 举报
回复
param的意思是控件加载的时候把他的某个属性赋值吗??
为什么我赋给他的值没有收到?? 而直接用代码他确可以收到??
网页自由打印控件使用方法功能:本控件可以在浏览器直接实现任意定位打印;用途:适用于B/S系统的报表打印,尤其适用于票据打印和套打;现在这个新编写的DLL控件比以前发布的OCX更稳定使用前,先注册一下,运行目录下的“注册控件.bat”即可注册然后在网页直接调用卸载时运行“反注册控件.bat”使用方法:在网页可以直接用JavaScript和VBScript调用被控件JavaScript调用语句:TML = new ActiveXObject("TML.TMLi");VBScript调用语句:set TML=CreateObject("TML.TMLi") ‘创建对象,DLL库名为TML,其TMLi为对象控件包含两个函addTXT "作者,字体,字号,X坐标,Y坐标,文字"p dmPaperWidth文档宽,dmPaperLength文档长addTXT语句为添加文字到打印文档,参有"作者,字体,字号,X坐标,Y坐标,文字"p语句为打印函,格式:dmPaperWidth文档宽,dmPaperLength文档长以下为完整的VBScript打印程序:(查看源代码) <script language="vbscript">set TML=CreateObject("TML.TMLi") ‘创建对象,DLL库名为TML,其TMLi为对象TML.addTXT "李天盟,华文宋,24,100,200,额外认为" ‘本addTXT语句为添加文字到打印文档TML.addTXT "李天盟,华文宋,12,110,300,额外认为" ‘格式为"作者,字体,字号,X坐标,Y坐标,文字"TML.addTXT "李天盟,华文宋,12,120,320,┏━━━━━━━━━━━━━━━━┓"TML.addTXT "李天盟,华文宋,12,120,325,┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ "TML.p 3000,2000 ‘语句p为打印函,格式:dmPaperWidth文档宽,dmPaperLength文档长set TML=nothing

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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