+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// wxActiveXEvents
+//
+// Handles and sends activex events received from the ActiveX control
+// to the appropriate wxEvtHandler
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+class wxActiveXEvents : public IDispatch
+{
+private:
+ DECLARE_OLE_UNKNOWN(wxActiveXEvents);
+
+
+ wxActiveXContainer *m_activeX;
+ IID m_customId;
+ bool m_haveCustomId;
+
+ friend bool wxActiveXEventsInterface(wxActiveXEvents *self, REFIID iid, void **_interface, const char *&desc);
+
+public:
+ wxActiveXEvents(wxActiveXContainer *ax) : m_activeX(ax), m_haveCustomId(false) {}
+ wxActiveXEvents(wxActiveXContainer *ax, REFIID iid) : m_activeX(ax), m_haveCustomId(true), m_customId(iid) {}
+ virtual ~wxActiveXEvents()
+ {
+ }
+
+ // IDispatch
+ STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR**, unsigned int, LCID, DISPID*)
+ {
+ return E_NOTIMPL;
+ }
+
+ STDMETHODIMP GetTypeInfo(unsigned int, LCID, ITypeInfo**)
+ {
+ return E_NOTIMPL;
+ }
+
+ STDMETHODIMP GetTypeInfoCount(unsigned int*)
+ {
+ return E_NOTIMPL;
+ }
+
+
+ STDMETHODIMP Invoke(DISPID dispIdMember, REFIID WXUNUSED(riid),
+ LCID WXUNUSED(lcid),
+ WORD wFlags, DISPPARAMS * pDispParams,
+ VARIANT * WXUNUSED(pVarResult), EXCEPINFO * WXUNUSED(pExcepInfo),
+ unsigned int * WXUNUSED(puArgErr))
+ {
+ if (wFlags & (DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF))
+ return E_NOTIMPL;
+
+ wxASSERT(m_activeX);
+
+ // ActiveX Event
+
+ // Dispatch Event
+ wxActiveXEvent event;
+ event.SetEventType(wxEVT_ACTIVEX);
+ event.m_params.NullList();
+ event.m_dispid = dispIdMember;
+
+ // arguments
+ if (pDispParams)
+ {
+ for (DWORD i = pDispParams->cArgs; i > 0; i--)
+ {
+ VARIANTARG& va = pDispParams->rgvarg[i-1];
+ wxVariant vx;
+
+// vx.SetName(px.name);
+ wxConvertOleToVariant(va, vx);
+ event.m_params.Append(vx);
+ }
+ }
+
+ // process the events from the activex method
+ m_activeX->ProcessEvent(event);
+ for (DWORD i = 0; i < pDispParams->cArgs; i++)
+ {
+ VARIANTARG& va = pDispParams->rgvarg[i];
+ wxVariant& vx =
+ event.m_params[pDispParams->cArgs - i - 1];
+ wxConvertVariantToOle(vx, va);
+ }
+
+ if(event.GetSkipped())
+ return DISP_E_MEMBERNOTFOUND;
+
+ return S_OK;
+ }
+};
+
+bool wxActiveXEventsInterface(wxActiveXEvents *self, REFIID iid, void **_interface, const char *&desc)
+{
+ if (self->m_haveCustomId && IsEqualIID(iid, self->m_customId))
+ {
+// WXOLE_TRACE("Found Custom Dispatch Interface");
+ *_interface = (IUnknown *) (IDispatch *) self;
+ desc = "Custom Dispatch Interface";
+ return true;
+ }
+
+ return false;
+}
+
+DEFINE_OLE_TABLE(wxActiveXEvents)
+ OLE_IINTERFACE(IUnknown)
+ OLE_INTERFACE(IID_IDispatch, IDispatch)
+ OLE_INTERFACE_CUSTOM(wxActiveXEventsInterface)
+END_OLE_TABLE
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//
+// wxActiveXContainer
+//
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+//---------------------------------------------------------------------------
+// wxActiveXContainer Constructor
+//
+// Initializes members and creates the native ActiveX container
+//---------------------------------------------------------------------------
+wxActiveXContainer::wxActiveXContainer(wxWindow * parent,
+ REFIID iid, IUnknown* pUnk)