还是Activex传参param问题!看了很多人的贴子,可就是没能解决我的问题!
我用MFC向导做了一个Activex要在网页中使用,是按照下方法添加属性的
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.
现在就是我在activex容器中测试时可以设置和取得ServerName值,一到网页中又不行了,得到都是初始化的值"www.realwnc.com",我的网页代码是:
<object ID="FolderView"
classid="clsid:C62BD9A9-1DA3-443A-B2C8-2C652C5B1315"
width="25%" height="99%"
CodeBase="http://localhost/activex/FolderView.cab#version=1,0,0,1">
<param name="ServerName" value="wzg">
</object>
控件中有这一句
PX_String(pPX,_T("ServerName"),g_strServerName,"www.realwnc.com");//g_strServerName是全局变量!
这是为什么呀,搞了一二天,还不行,快来打救呀!
问题点数:100、回复次数:9Top
1 楼linestyle(linestyle)回复于 2005-06-03 13:12:16 得分 0
PX_String有返回值的,你可以看看
Return Value Nonzero if the exchange was successful; 0 if unsuccessful.
Top
2 楼alornwolf(天山雪狼)回复于 2005-06-03 13:21:27 得分 0
PX_String返回值是不等于0 的,也就是对的,
我在容器里测试都可以对ServerName设值和取值,就是在网页是无法设值,到得到都是初始化的值!
怎解决呀,有谁有这样的例子,发一个给我了!
realwnc@163.comTop
3 楼krh2001(边城浪子)回复于 2005-06-03 13:28:32 得分 100
我给你发例子, 这个问题以前有人问过我,我找到原因了Top
4 楼alornwolf(天山雪狼)回复于 2005-06-03 14:07:16 得分 0
TO: krh2001(边城浪子)
我的代码跟你的几乎一样了,唯一不同的是我把g_strServerName声明为全局变量,因为我要在其它地方调用.
但这样还是不行,容器里可以,但网页中就是传不到值!
<object ID="FolderView"
classid="clsid:C62BD9A9-1DA3-443A-B2C8-2C652C5B1315"
width="25%" height="99%"
CodeBase="http://localhost/activex/FolderView.cab#version=1,0,0,1">
<param name="ServerName" value="wzg">
</object>
网页这样写没有错吧??Top
5 楼sinall()回复于 2005-06-04 09:42:04 得分 0
^_^,我可以负责任地告诉你,可以传。
问题应该出在你的IE上,可能是安全级别设置不当。
我的IE打开的时候提示:
“在此页上地ActiveX控件和本页上地其他部份地交互可能部安全。你想允许这种交互吗?”
点“是”,显示设置值,点“否”,显示默认值。Top
6 楼xxrl(孔曰成仁,孟曰取媳妇-->她太有才了)回复于 2005-06-06 08:20:16 得分 0
两种防范:
要么做签名 这个论坛里有解 搜索
要么把安全那个对话框给去掉 这个论坛里面有答案Top
7 楼alornwolf(天山雪狼)回复于 2005-06-06 09:08:20 得分 0
我现在碰到更怪的事,有的机器可以传参,有的机器不可以传参!
这是为什么??Top
8 楼linestyle(linestyle)回复于 2005-06-06 09:41:07 得分 0
你实现ISafeObject接口试一试啊:)Top
9 楼shines(郭子)回复于 2005-06-22 02:55:44 得分 0
markTop




