// With Borland C++, all samples crash if this is compiled in.
#if wxUSE_OLE &&!defined(__WATCOMC__) && !(defined(__BORLANDC__) && (__BORLANDC__ < 0x520)) && !defined(__CYGWIN10__)
+#define _FORCENAMELESSUNION
#include "wx/log.h"
#include "wx/msw/ole/automtn.h"
#include "wx/msw/private.h"
if (FAILED(hr))
{
// ShowException(szMember, hr, NULL, 0);
+ delete[] argNames;
+ delete[] dispIds;
return FALSE;
}
{
// Again, reverse args
if (!ConvertVariantToOle(INVOKEARG((noArgs-1) - i), oleArgs[i]))
- return FALSE; // TODO: clean up memory at this point
+ {
+ delete[] argNames;
+ delete[] dispIds;
+ delete[] oleArgs;
+ return FALSE;
+ }
}
dispparams.rgdispidNamedArgs = dispIds + 1;
return retVariant;
}
+wxVariant wxAutomationObject::CallMethodArray(const wxString& member, int noArgs, const wxVariant **args)
+{
+ wxVariant retVariant;
+ if (!Invoke(member, DISPATCH_METHOD, retVariant, noArgs, NULL, args))
+ {
+ retVariant.MakeNull();
+ }
+ return retVariant;
+}
+
wxVariant wxAutomationObject::CallMethod(const wxString& member,
const wxVariant& arg1, const wxVariant& arg2,
const wxVariant& arg3, const wxVariant& arg4,
}
// Get/Set property
+wxVariant wxAutomationObject::GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const
+{
+ wxVariant retVariant;
+ if (!Invoke(property, DISPATCH_PROPERTYGET, retVariant, noArgs, NULL, args))
+ {
+ retVariant.MakeNull();
+ }
+ return retVariant;
+}
wxVariant wxAutomationObject::GetProperty(const wxString& property, int noArgs, wxVariant args[]) const
{
wxVariant retVariant;
return TRUE;
}
+bool wxAutomationObject::PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args)
+{
+ wxVariant retVariant;
+ if (!Invoke(property, DISPATCH_PROPERTYPUT, retVariant, noArgs, NULL, args))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
bool wxAutomationObject::PutProperty(const wxString& property,
const wxVariant& arg1, const wxVariant& arg2,
const wxVariant& arg3, const wxVariant& arg4,
return (WXIDISPATCH*) NULL;
}
+// Uses DISPATCH_PROPERTYGET
+// and returns a dispatch pointer. The calling code should call Release
+// on the pointer, though this could be implicit by constructing an wxAutomationObject
+// with it and letting the destructor call Release.
+WXIDISPATCH* wxAutomationObject::GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const
+{
+ wxVariant retVariant;
+ if (Invoke(property, DISPATCH_PROPERTYGET, retVariant, noArgs, NULL, args))
+ {
+ if (retVariant.GetType() == wxT("void*"))
+ {
+ return (WXIDISPATCH*) retVariant.GetVoidPtr();
+ }
+ }
+
+ return (WXIDISPATCH*) NULL;
+}
+
+
// A way of initialising another wxAutomationObject with a dispatch object
bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, wxVariant args[]) const
{
return FALSE;
}
+// A way of initialising another wxAutomationObject with a dispatch object
+bool wxAutomationObject::GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const
+{
+ WXIDISPATCH* dispatch = GetDispatchProperty(property, noArgs, args);
+ if (dispatch)
+ {
+ obj.SetDispatchPtr(dispatch);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
// Get a dispatch pointer from the current object associated
// with a class id
bool wxAutomationObject::GetInstance(const wxString& classId) const
wxString type(variant.GetType());
+
if (type == wxT("long"))
{
oleVariant.vt = VT_I4;
oleVariant.lVal = variant.GetLong() ;
}
+ // cVal not always present
+#ifndef __GNUWIN32__
+ else if (type == wxT("char"))
+ {
+ oleVariant.vt=VT_I1; // Signed Char
+ oleVariant.cVal=variant.GetChar();
+ }
+#endif
else if (type == wxT("double"))
{
oleVariant.vt = VT_R8;
static wxString ConvertStringFromOle(BSTR bStr)
{
+#if wxUSE_UNICODE
+ wxString str(bStr);
+#else
int len = SysStringLen(bStr) + 1;
char *buf = new char[len];
(void)wcstombs( buf, bStr, len);
-
- wxString str(buf);
+ wxString str(buf);
delete[] buf;
+#endif
return str;
}