在activex中添加了几个属性,如下。
[id(1)] BSTR strServerIP; BSTR CMonitorActivexCtrl::GetStrServerIP()
{
CString strResult;
// TODO: Add your property handler here return strResult.AllocSysString();
} void CMonitorActivexCtrl::SetStrServerIP(LPCTSTR lpszNewValue)
{
// TODO: Add your property handler here
m_strServerIP = lpszNewValue; SetModifiedFlag();
} void CMonitorActivexCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
if (pPX->GetVersion() == (DWORD)MAKELONG(_wVerMinor, _wVerMajor))
{
PX_String(pPX,_T("strServerIP"),m_strServerIP);
} // TODO: Call PX_ functions for each persistent custom property. } 控件需要在web中调用。如下。
<OBJECT id="MonitorActivex" codeBase="MonitorActivex.ocx#version=1,0,0,1" height="100%" width="100%" classid="clsid:7C4DF13F-B090-4328-85DC-FEE93699F7E3">
<PARAM NAME="strServerIP" VALUE="192.168.0.172"> </PARAM>
</OBJECT> 如果没有下面这一部分,控件能连接到服务器192.168.0.172。如果用下面的方式动态配置服务器192.168.0.111,控件不能连接到111。
<script type="javascript">
//通过断点,可是看到,web走到这个位置就停下来了。是不是我的变量声明的问??
MonitorActivex.strServerIP= "192.168.0.111";
[id(1)] BSTR strServerIP; BSTR CMonitorActivexCtrl::GetStrServerIP()
{
CString strResult;
// TODO: Add your property handler here return strResult.AllocSysString();
} void CMonitorActivexCtrl::SetStrServerIP(LPCTSTR lpszNewValue)
{
// TODO: Add your property handler here
m_strServerIP = lpszNewValue; SetModifiedFlag();
} void CMonitorActivexCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
if (pPX->GetVersion() == (DWORD)MAKELONG(_wVerMinor, _wVerMajor))
{
PX_String(pPX,_T("strServerIP"),m_strServerIP);
} // TODO: Call PX_ functions for each persistent custom property. } 控件需要在web中调用。如下。
<OBJECT id="MonitorActivex" codeBase="MonitorActivex.ocx#version=1,0,0,1" height="100%" width="100%" classid="clsid:7C4DF13F-B090-4328-85DC-FEE93699F7E3">
<PARAM NAME="strServerIP" VALUE="192.168.0.172"> </PARAM>
</OBJECT> 如果没有下面这一部分,控件能连接到服务器192.168.0.172。如果用下面的方式动态配置服务器192.168.0.111,控件不能连接到111。
<script type="javascript">
//通过断点,可是看到,web走到这个位置就停下来了。是不是我的变量声明的问??
MonitorActivex.strServerIP= "192.168.0.111";
这里的参数类型应该为BSTR*
这个写法是正确的,我想问题应该出现在ocx中。
<PARAM NAME="strServerIP" VALUE="192.168.0.172"> </PARAM>
</OBJECT> 这一部分好用,估计strServerIP属性名称应该是设置正确的。你在动态设置这个IP的时候,是否有其他内部函数通过线程在访问具体的IP地址,那样的话,你两个不同的IP地址修改,会不会导致问题!?