+namespace
+{
+// just a unique global variable
+const int invalid_entry_marker = 0;
+}
+
+wxVariant wxActiveXEvents::ms_invalidEntryMarker((void*)&invalid_entry_marker);
+
+size_t wxActiveXEvent::ParamCount() const
+{
+ wxActiveXEventNativeMSW *native=GetNativeParameters();
+ // 'native' will always be != if the event has been created
+ // for an actual active X event.
+ // But it may be zero if the event has been created by wx program code.
+ if (native)
+ return native->pDispParams ? native->pDispParams->cArgs : 0;
+
+ return m_params.GetCount();
+}
+
+wxVariant &wxActiveXEvent::operator [](size_t idx)
+{
+ wxASSERT(idx < ParamCount());
+ wxActiveXEventNativeMSW *native=GetNativeParameters();
+ // 'native' will always be != if the event has been created
+ // for an actual active X event.
+ // But it may be zero if the event has been created by wx program code.
+ if (native)
+ {
+ while ( m_params.GetCount()<=idx )
+ {
+ m_params.Append(wxActiveXEvents::ms_invalidEntryMarker);
+ }
+
+ wxVariant& vx = m_params[idx];
+ if ( vx.IsType(wxActiveXEvents::ms_invalidEntryMarker.GetType()) &&
+ vx == wxActiveXEvents::ms_invalidEntryMarker)
+ {
+ // copy the _real_ parameter into this one
+ // NOTE: m_params stores the parameters in *reverse* order.
+ // Whyever, but this was the case in the original implementation of
+ // wxActiveXEvents::Invoke
+ // Keep this convention.
+ VARIANTARG& va = native->pDispParams->rgvarg[ native->pDispParams->cArgs - idx - 1 ];
+ wxConvertOleToVariant(va, vx);
+ }
+ return vx;
+ }
+ return m_params[idx];
+}
+