c++ - How to add any reusable interface for an ActiveX control using MFC? -
i have activex control container accepts predefined set of interfaces (properties). need design quite few mfc activex controls expose properties, initial attempt create interface class contains required properties pure virtual members , activex control inherit interface class. activex control have interfaces inherited, how can expose them container? if use class wizard add properties, know can expose them. whole point avoid adding them 1 one each activex control. if don't use class wizard, mean have manually modify begin_dispatch_map() & end_dispatch_map() section , corresponding .odl file, don't think thing do.
so question is, using mfc, how can inherit abstract class (interface class) implement predefined properties (interfaces) activex control , expose them user?
example: base class has property defined as: long newproperty. , activex control b inherit a, b has newproperty. question how expose newproperty in b? how can have , set functions new property using class wizard? , have manually modify begin_dispatch_map() & end_dispatch_map() section , corresponding .odl file?
you want access activex controls programmatically, not using class wizard generated wrappers, if understand correctly? well, bit cumbersome. example, calls member funktion mymemberfunction long
parameter 123456789:
atlaxwininit(); pmyactivexwnd = new caxwindow(); pmyactivexwnd ->create(...) lpunknown punk; pmyactivexwnd ->querycontrol(&punk); idispatch *spdispatch; hresult hres = punk->queryinterface(__uuidof(spdispatch), (void **) &spdispatch); dispid dispid; dispparams dispparams = { null, null, 0, 0 }; variant vret; colevariant vparam((long)123456789,vt_i4); excepinfo excepinfo; uint nargerr; dispparams.rgvarg = (lpvariant)vparam; dispparams.cargs = 1; dispparams.cnamedargs = 0; hres = spdispatch->getidsofnames(iid_null, _t("mymemberfunction"), 1, locale_system_default, &dispid); hres = spdispatch->invoke(dispid, iid_null, locale_system_default, dispatch_method, &dispparams, &vret, &excepinfo, &nargerr);