Re: how to write a base implementation class for common activex contro?
"thinktwice" <memorialday@gmail.com> wrote in message
news:1155174309.821594.81270@h48g2000cwc.googlegroups.com
most atl activex control class would look like this
class ATL_NO_VTABLE CMyControl:
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IMyControlInterface, &IID_IMyControlInterface,
&LIBID>,
public CComControl<CMyControl>,
public IPersistStreamInitImpl<CMyControl>,
public IOleControlImpl<CMyControl>,
[snip]
is it possible to write a common base class so i could just write my
control like this
class CMyControl: public CBaseControlImpl<CMyControl, TInterface,
TEventInterface, clisid, libid...>
{
}
I don't see why not. Something like
template <class T, CLSID* clsid, ...>
class CBaseControlImpl :
public CComObjectRootEx<CComSingleThreadModel>,
public CComControl<T>,
public IPersistStreamInitImpl<T>,
public IOleControlImpl<T>,
...
{
BEGIN_COM_MAP(CBaseControlImpl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IOleControl)
...
END_COM_MAP()
};
class CMyControl :
public CBaseControlImpl<CMyControl, ...>,
...
{
private:
typename CBaseControlImpl<CMyControl, ...> BaseClass;
public:
BEGIN_COM_MAP(CMyControl)
COM_INTERFACE_ENTRY(IMyInterface)
COM_INTERFACE_ENTRY_CHAIN(BaseClass)
END_COM_MAP()
};
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925