3

Is there an easy way to create a class that is derived from IDispatch and that can be passed to API like this (this is C++ ):

pDOM2->attachEvent(CComBSTR("event"), new DispatchFunction);

I know how to create a C++ object that handle an invoke with a dispid of value 0 but it's always a bit painful to implement all IDispatch by hand. I was wondering if ATL has some standard way of doing it as it is fairly common.

Emmanuel Caradec
  • 2,302
  • 1
  • 19
  • 38

1 Answers1

2

By default ATL creates "auto-dual" COM classes. They support both early binding and IDispatch. You'll see IDispatchImpl<> in their inheritance list. You declare the dispid in the IDL. No extra work is required.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536