简体   繁体   中英

How to create anonymous IDispatch functions with ATL?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM