I've implemented the Visual Studio Application model (VC6) in a small app
that I can test add-ins with. All-in-all it worked fine (ie direct calls of
IApplication etc methods), except IDispatch calls (I simply done dummy
implemenation of the IDispatch methods), besides,I thought I should do it
nicer, more ATL-ish. Being fairly new to ATL (its also an exercise/excuse to
work with ATL) I can't get the implementing of the IDispatch straight.
With a class declaration as:
class ATL_NO_VTABLE CApplicationStub :
public IApplication, // The iface I want to implement (it defines the
various IDispatch methods as pure virtual)
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CApplicationStub, &CLSID_ApplicationStub>,
public IDispatchImpl<IApplicationStub, &IID_IApplicationStub,
&LIBID_ATLTestLib>
{
public:
CApplicationStub()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_APPLICATIONSTUB)
DECLARE_PROTECT_FINAL_CONSTRUCT()
BEGIN_COM_MAP(CApplicationStub)
COM_INTERFACE_ENTRY(IApplicationStub)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
// etc...
I keep getting "cannot instantiate abstract class due to .... long __stdcall
IApplication::GetTypeInfoCount(unsigned int *)" and the other IDispatch
methods as well.
I thought these methods are implemented by the IDispatchImpl template class.
Well, obviously not since I get the error...
What am I stupidely missing? (Im instantiating using the CComObject< >
template)
As a workaround I've tried to implement the IDispath methods like this
STDMETHOD(GetTypeInfo)(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
{
return IDispatchImpl<IApplicationStub, &IID_IApplicationStub,
&LIBID_ATLTestLib>::GetTypeInfo(...params...);
}
but that didn't do the trick as the client's Invoke will still fail. The
m_pInfo member if the CComTypeInfoHolder in question is NULL.
Any ideas (a firm kick in the right direction will do :-)?
Thanks
--
/Per N.
perfnurt at hotmail dot com
"It was a work of art, flawless, sublime. A triumph equaled only by its
monumental failure."
- The Architect
Now, reading over again, I'm not sure if you didn't mean something
else. Perhaps IApplication is the real dual interface you want to
implement. In that case replace IApplicationStub with IApplication
both in the IDispatchImpl argument and the interface map, then
drop the explicit derivation from IApplication. IApplicationStub
disappears entirely - you can safely remove it from the IDL file
as well, and change the coclass to specify IApplication instead.
Don't forget to importlib() the correct type library as needed. And
don't forget to change the LIBID in the IDispatchImpl template
(and specify explicit version perhaps) too - to the type library
that defines your IApplication interface.
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Per Nilsson" <perfnurtAThotmailDOTcom> wrote in message news:uiWTqRj%23DHA...@tk2msftngp13.phx.gbl...
All I have (so far :-) ) is the definition of IApplication:
...\VC98\Include\ObjModel\APPAUTO.H
and the definition of IID_IApplication:
...\VC98\Include\ObjModel\APPGUID.H
I thought that knowing these should be sufficient as I have no trouble with
the non-IDispatch related methods (ie I can handle
when the add-in calls for example IApplication::AddCommand), but should the
client call the IDispatch methods, well,
I get a bit lost.
--
/Per N.
perfnurt at hotmail dot com
"It was a work of art, flawless, sublime. A triumph equaled only by its
monumental failure."
- The Architect
"Alexander Nickolov" <agnic...@mvps.org> skrev i meddelandet
news:u%23YUmRk%23DHA...@TK2MSFTNGP10.phx.gbl...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Per Nilsson" <perfnurtAThotmailDOTcom> wrote in message news:%23jiZoqk%23DHA...@TK2MSFTNGP12.phx.gbl...
Thanks a lot!
/Per N.
perfnurt at hotmail dot com
"It was a work of art, flawless, sublime. A triumph equaled only by its
monumental failure."
- The Architect
"Alexander Nickolov" <agnic...@mvps.org> skrev i meddelandet
news:%233TvIYl%23DHA...@tk2msftngp13.phx.gbl...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Per Nilsson" <perfnurtAThotmailDOTcom> wrote in message news:OkhW34l%23DH...@TK2MSFTNGP12.phx.gbl...