宝石回归 请问是谁你回会VEX吗???

《好看》依托百度技术,精准推荐优质短视频内容,懂你所好,量身打造最适合你的短视频客户端!开发atcivex时,如何设置能 将一个方法返回一个com的类的实例?
20分,无满意结帖,结帖人djliu221]
开发atcivex时,如何设置能 将一个方法返回一个com的类的实例?
20分,无满意结帖,结帖人djliu221]
编辑:www.fx114.net
本篇文章主要介绍了"开发atcivex时,如何设置能 将一个方法返回一个com的类的实例?
20分,无满意结帖,结帖人djliu221]",主要涉及到开发atcivex时,如何设置能 将一个方法返回一个com的类的实例?
20分,无满意结帖,结帖人djliu221]方面的内容,对于开发atcivex时,如何设置能 将一个方法返回一个com的类的实例?
20分,无满意结帖,结帖人djliu221]感兴趣的同学可以参考一下。
开发atcivex时,如何设置能&将一个方法返回一个com的类的实例?就是返回接口指针吧?
在idl中定义好该接口,写个类实现该接口返回就行了class&CMapXD
class&CMapX&:&public&CWnd
protected:
DECLARE_DYNCREATE(CMapX)
CLSID&const&&GetClsid()
static&CLSID&const&clsid&=
{&0x9d6ed188,&0xd2,&&{&0x98,&0xa6,&0x0,&0xa0,&0xc9,&0x74,&0x2c,&0xca&}&};
virtual&BOOL&Create(LPCTSTR&lpszClassName,
LPCTSTR&lpszWindowName,&DWORD&dwStyle,
const&RECT&&rect,
CWnd*&pParentWnd,&UINT&nID,
CCreateContext*&pContext&=&NULL)
{&return&CreateControl(GetClsid(),&lpszWindowName,&dwStyle,&rect,&pParentWnd,&nID);&}
BOOL&Create(LPCTSTR&lpszWindowName,&DWORD&dwStyle,
const&RECT&&rect,&CWnd*&pParentWnd,&UINT&nID,
CFile*&pPersist&=&NULL,&BOOL&bStorage&=&FALSE,
BSTR&bstrLicKey&=&NULL)
{&return&CreateControl(GetClsid(),&lpszWindowName,&dwStyle,&rect,&pParentWnd,&nID,
pPersist,&bStorage,&bstrLicKey);&}
class&CMapX&:&public&COleDispatchDriver
&&& CMapXDatasets&GetDatasets();
class&CMapXDatasets&:&public&COleDispatchDriver
CMapXDatasets()&{} //&Calls&COleDispatchDriver&default&constructor
CMapXDatasets(LPDISPATCH&pDispatch)&:&COleDispatchDriver(pDispatch)&{}
CMapXDatasets(const&CMapXDatasets&&dispatchSrc)&:&COleDispatchDriver(dispatchSrc)&{}
//&Attributes
long&GetCount();
CMapXDataset&operator[](long&Index)&{&return&Item(Index);&}
CMapXDataset&operator[](LPCTSTR&Index)&{&return&Item(Index);&}
BOOL&GetBuildSourceRows();
void&SetBuildSourceRows(BOOL&b);
//&Operations
CMapXDataset&Add(long&Type,&const&VARIANT&&SourceData,&const&VARIANT&&Name,&const&VARIANT&&GeoField,&const&VARIANT&&SecondaryGeoField,&const&VARIANT&&BindLayer,&const&VARIANT&&Fields,&const&VARIANT&&Dynamic);
CMapXDataset&Add(short&Type,&const&VARIANT&&SourceData,&LPCTSTR&Name=NULL,&long&GeoField=0)
{&return&Add(Type,&SourceData,&COleVariant(Name),&COleVariant(GeoField),
COptionalVariant(),&COptionalVariant(),&COptionalVariant(),&COptionalVariant());
CMapXDataset&Item(const&VARIANT&&Index);
CMapXDataset&Item(long&Index)&{&return&Item(COleVariant(Index));&}
CMapXDataset&Item(LPCTSTR&Index)&{&return&Item(COleVariant(Index));&}
void&Remove(const&VARIANT&&Index);
void&Remove(long&Index)&{&Remove(COleVariant(Index));&}
void&Remove(LPCTSTR&Index)&{&Remove(COleVariant(Index));&}
CMapXDataset&Restore(LPCTSTR&Name,&const&VARIANT&&SourceData);
void&RemoveAll();
看&这段代码,如何达到这个效果你需要将CMapXDataset做成CoClass
也就是你的这个COM中需要CMapX、CMapXDataset两个CoClass
CMapX实现IMapX,CMapXDataset实现IMapXDataset,然后Item属性为IMapXDataset类型
至于如何让Item被包装成CMapXDataset,我就不清楚了这个如何做?详细说,以一个简单的例子来讲,可以&吗?
还有,能直接联系你吗?
msn&STDMETHODIMP&CAdViewerEx::get_ECompositeViewer(IDispatch&**pVal)
//&TODO:&Add&your&implementation&code&here
CComObject&&&CAdECompositeViewerEx&&*&pTmpAdECompositeviewerEx&=&new&CComObject&&CAdECompositeViewerEx&&();
pTmpAdECompositeviewerEx-&AddRef();
pTmpAdECompositeviewerEx-&m_pAdECompositeViewer&=&IAdDwfViewerPtr(m_pAdView)-&GetECompositeViewer();
pTmpAdECompositeviewerEx-&QueryInterface(IID_IUnknown,(void**)pVal);
catch&(_com_error&&e)
m_bstrError&=&e.ErrorMessage();
return&S_FALSE;
return&S_OK;
一个简单的例子希望能给你帮助.这2个没有关系啊?实现起来有点麻烦,不过是完全可行的。
你实现一个双接口,并返回他就可以了。如何能实现我给的代码哪个效果,用mfcSTDMETHODIMP&CYourCtl::get_AClass(IAClass**&pVal)
CComObject&CAClass&*&pAC
CComObject&CAClass&::CreateInstance(&pAClass);
pAClass-&AddRef();
pAClass-&...//调用接口实现功能
pAClass-&QueryInterface(pVal);
pAClass-&Release();
IAClass是你要返回的接口情况是这样的:
我开发一个ocx&&如何能达到这样的效果:(用mfc开发ocx)
class&CMapXD&
class&CMapX&:&public&CWnd&
protected:&
DECLARE_DYNCREATE(CMapX)&
CLSID&const&&GetClsid()&
static&CLSID&const&clsid&=&
{&0x9d6ed188,&0xd2,&&{&0x98,&0xa6,&0x0,&0xa0,&0xc9,&0x74,&0x2c,&0xca&}&};&
virtual&BOOL&Create(LPCTSTR&lpszClassName,&
LPCTSTR&lpszWindowName,&DWORD&dwStyle,&
const&RECT&&rect,&
CWnd*&pParentWnd,&UINT&nID,&
CCreateContext*&pContext&=&NULL)&
{&return&CreateControl(GetClsid(),&lpszWindowName,&dwStyle,&rect,&pParentWnd,&nID);&}&
BOOL&Create(LPCTSTR&lpszWindowName,&DWORD&dwStyle,&
const&RECT&&rect,&CWnd*&pParentWnd,&UINT&nID,&
CFile*&pPersist&=&NULL,&BOOL&bStorage&=&FALSE,&
BSTR&bstrLicKey&=&NULL)&
{&return&CreateControl(GetClsid(),&lpszWindowName,&dwStyle,&rect,&pParentWnd,&nID,&
pPersist,&bStorage,&bstrLicKey);&}&
class&CMapX&:&public&COleDispatchDriver&
&&CMapXDatasets&GetDatasets();&
class&CMapXDatasets&:&public&COleDispatchDriver&
CMapXDatasets()&{}&//&Calls&COleDispatchDriver&default&constructor&
CMapXDatasets(LPDISPATCH&pDispatch)&:&COleDispatchDriver(pDispatch)&{}&
CMapXDatasets(const&CMapXDatasets&&dispatchSrc)&:&COleDispatchDriver(dispatchSrc)&{}&
//&Attributes&
long&GetCount();&
CMapXDataset&operator[](long&Index)&{&return&Item(Index);&}&
CMapXDataset&operator[](LPCTSTR&Index)&{&return&Item(Index);&}&
BOOL&GetBuildSourceRows();&
void&SetBuildSourceRows(BOOL&b);&
//&Operations&
CMapXDataset&Add(long&Type,&const&VARIANT&&SourceData,&const&VARIANT&&Name,&const&VARIANT&&GeoField,&const&VARIANT&&SecondaryGeoField,&const&VARIANT&&BindLayer,&const&VARIANT&&Fields,&const&VARIANT&&Dynamic);&
CMapXDataset&Add(short&Type,&const&VARIANT&&SourceData,&LPCTSTR&Name=NULL,&long&GeoField=0)&
{&return&Add(Type,&SourceData,&COleVariant(Name),&COleVariant(GeoField),&
COptionalVariant(),&COptionalVariant(),&COptionalVariant(),&COptionalVariant());&
CMapXDataset&Item(const&VARIANT&&Index);&
CMapXDataset&Item(long&Index)&{&return&Item(COleVariant(Index));&}&
CMapXDataset&Item(LPCTSTR&Index)&{&return&Item(COleVariant(Index));&}&
void&Remove(const&VARIANT&&Index);&
void&Remove(long&Index)&{&Remove(COleVariant(Index));&}&
void&Remove(LPCTSTR&Index)&{&Remove(COleVariant(Index));&}&
CMapXDataset&Restore(LPCTSTR&Name,&const&VARIANT&&SourceData);&
void&RemoveAll();&
};&&可以实现。这2个没有关系啊?这两个是没有关系,不过它实现了如何返回一个接口指针
一、不得利用本站危害国家安全、泄露国家秘密,不得侵犯国家社会集体的和公民的合法权益,不得利用本站制作、复制和传播不法有害信息!
二、互相尊重,对自己的言论和行为负责。
本文标题:
本页链接:

参考资料

 

随机推荐