DISPID ---- Identifies the method or property to be invoked. This value is usually supplied by Component Gallery.
解决方案 »
- 不能将参数 2 从“const wchar_t [8]”转换为“LPCSTR”
- 如何为对话框添加一个透明位图,并可以自动拉伸?
- 100分,求用对话框显示"生产者与消费者"模型
- 急问T_T,请问一个使用VC++,CSocket的聊天室程序,我怎么看它的通信协议是怎样的?
- 进程崩溃时候如何做到千千静听类似的详细崩溃信息显示?
- CArray的嵌套?
- 请问一个小问题:
- 将socket改为非阻塞后程序还是在等待,如何加决???代码是。。。。。
- 要写一个播放Vob文件的播放器,大家给点想法.
- 问:如何把一个int值赋给枚举变量?
- 关于列表框的简单问题 ----->> 40分 ...
- pDC->LineTo(...)问题。
DISPID_VALUE The default member for the object. This property or method is invoked when an ActiveX client specifies the object name without a property or method.
DISPID_NEWENUM The _NewEnum property. This special, restricted property is required for collection objects. It returns an enumerator object that supports IEnumVARIANT, and should have the restricted attribute specified in Object Description Language.
DISPID_EVALUATE The Evaluate method. This method is implicitly invoked when the ActiveX client encloses the arguments in square brackets. For example, the following two lines are equivalent:
x.[A1:C1].value = 10
x.Evaluate("A1:C1").value = 10The Evaluate method has the DISPID DISPID_EVALUATE.
DISPID_PROPERTYPUT The parameter that receives the value of an assignment in a PROPERTYPUT.
DISPID_CONSTRUCTOR The C++ constructor function for the object.
DISPID_DESTRUCTOR The C++ destructor function for the object.
DISPID_UNKNOWN The value returned by IDispatch::GetIDsOfNames to indicate that a member or parameter name was not found.
我是这样写代码的:
void CTcfnewCtrl::SetDBPath(LPCTSTR lpszNewValue)
{
static BYTE parms[]=VTS_BSTR;
InvokeHelper(0x1,DISPATCH_PROPERTYPUT,VT_EMPTY,NULL,parms,lpszNewValue);
m_datapath=lpszNewValue;//m_datapath是控件的一个成员变量
if(ConnectDatabase())//连接数据库,再控件中显示数据库中的内容
{
……
}
}
BSTR CTcfnewCtrl::GetDBPath()
{
CString strResult;
// TODO: Add your property handler here
strResult=m_datapath;
InvokeHelper(0x1,DISPATCH_PROPERTYGET,VT_BSTR,(void*)&strResult,NULL);
return strResult.AllocSysString();
}
不知道对不对?
这个控件是你自己写的吧!你的控件属性的调用很混乱!你的Set和Get函数最好加入返回值,这样才能知道调用是否成功!
//InvokeHelper(0x1,DISPATCH_PROPERTYPUT,VT_EMPTY,NULL,parms,lpszNewValue);
//m_datapath=lpszNewValue;//m_datapath是控件的一个成员变量
m_datapath既然是控件的一个成员变量,你怎么又能在你插入ActiveX的地方直接用到它?你应该在ActiveX内部编写STDMETHODIMP SetDBPath(BSTR lpsePath, short *pVal)
时,将lpszNewValue付给m_datapath,如果不成功,可用返回的short *pVal值表示错误的不同原因。
short CTcfnewCtrl::SetDBPath(LPCTSTR lpszNewValue)
{
short result;
static BYTE parms[] =
VTS_BSTR;
InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_I2, (void*)&result, parms,
lpszNewValue);
return result;
}
就可以了。
但CTcfnewCtrl::SetDBPath()函数应由classwizard来写,你只要专心写你的ActiveX就可以了。写好了ActiveX,在VC中利用ClassWizard把ActiveX封装进来,和别的MFC类一样用,没什么大区别。
CString CTcfnewCtrl::GetDBPath()
{
CString result;
InvokeHelper(0x1, DISPATCH_PROPERTYGet, VTS_BSTR, (void*)&result, NULL);
return result;
}
当然,这个函数也是ClassWizard自动写的!
CString CTcfnewCtrl::GetDBPath()
{
CString result;
InvokeHelper(0x1, DISPATCH_PROPERTYGet, VTS_BSTR, (void*)&result, NULL);
return result;
}
当然,这个函数也是ClassWizard自动写的!
下班了^_^