1998-12-08 13:54:05 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: automtn.h
|
|
|
|
// Purpose: OLE automation utilities
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 11/6/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998, Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-12-08 13:54:05 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_AUTOMTN_H_
|
|
|
|
#define _WX_AUTOMTN_H_
|
|
|
|
|
2006-09-24 09:12:56 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_OLE_AUTOMATION
|
|
|
|
|
1998-12-08 13:54:05 -05:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/variant.h"
|
|
|
|
|
|
|
|
typedef void WXIDISPATCH;
|
|
|
|
typedef unsigned short* WXBSTR;
|
|
|
|
|
1999-02-07 12:11:44 -05:00
|
|
|
#ifdef GetObject
|
|
|
|
#undef GetObject
|
|
|
|
#endif
|
|
|
|
|
1998-12-08 13:54:05 -05:00
|
|
|
/*
|
|
|
|
* wxAutomationObject
|
|
|
|
* Wraps up an IDispatch pointer and invocation; does variant conversion.
|
|
|
|
*/
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxAutomationObject: public wxObject
|
1998-12-08 13:54:05 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL);
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxAutomationObject();
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// Set/get dispatch pointer
|
2007-04-14 05:58:37 -04:00
|
|
|
inline void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; }
|
1998-12-08 13:54:05 -05:00
|
|
|
inline WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; }
|
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// Get a dispatch pointer from the current object associated
|
|
|
|
// with a class id, such as "Excel.Application"
|
|
|
|
bool GetInstance(const wxString& classId) const;
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// Get a dispatch pointer from a new instance of the the class
|
|
|
|
bool CreateInstance(const wxString& classId) const;
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// Low-level invocation function. Pass either an array of variants,
|
|
|
|
// or an array of pointers to variants.
|
1998-12-08 13:54:05 -05:00
|
|
|
bool Invoke(const wxString& member, int action,
|
|
|
|
wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = 0) const;
|
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// Invoke a member function
|
|
|
|
wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]);
|
|
|
|
wxVariant CallMethodArray(const wxString& method, int noArgs, const wxVariant **args);
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// Convenience function
|
|
|
|
wxVariant CallMethod(const wxString& method,
|
|
|
|
const wxVariant& arg1 = wxNullVariant, const wxVariant& arg2 = wxNullVariant,
|
|
|
|
const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
|
|
|
|
const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// Get/Put property
|
1998-12-08 13:54:05 -05:00
|
|
|
wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const;
|
2004-08-16 08:45:46 -04:00
|
|
|
wxVariant GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const;
|
|
|
|
wxVariant GetProperty(const wxString& property,
|
|
|
|
const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
|
|
|
|
const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
|
|
|
|
const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2002-06-26 03:33:02 -04:00
|
|
|
bool PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args);
|
1998-12-08 13:54:05 -05:00
|
|
|
bool PutProperty(const wxString& property, int noArgs, wxVariant args[]) ;
|
2004-08-16 08:45:46 -04:00
|
|
|
bool PutProperty(const wxString& property,
|
|
|
|
const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
|
|
|
|
const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
|
|
|
|
const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
|
|
|
|
|
|
|
|
// 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.
|
1998-12-08 13:54:05 -05:00
|
|
|
WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, wxVariant args[]) const;
|
2002-06-23 10:10:32 -04:00
|
|
|
WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const;
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2004-08-16 08:45:46 -04:00
|
|
|
// A way of initialising another wxAutomationObject with a dispatch object,
|
|
|
|
// without having to deal with nasty IDispatch pointers.
|
|
|
|
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const;
|
|
|
|
bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const;
|
1998-12-08 13:54:05 -05:00
|
|
|
|
|
|
|
public:
|
|
|
|
WXIDISPATCH* m_dispatchPtr;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxAutomationObject)
|
1998-12-08 13:54:05 -05:00
|
|
|
};
|
|
|
|
|
2006-09-24 09:12:56 -04:00
|
|
|
#endif // wxUSE_OLE_AUTOMATION
|
1998-12-08 13:54:05 -05:00
|
|
|
|
2006-09-24 09:12:56 -04:00
|
|
|
#endif // _WX_AUTOMTN_H_
|