1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: OLE automation utilities
4 // Author: Julian Smart
8 // Copyright: (c) 1998, Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_AUTOMTN_H_
13 #define _WX_AUTOMTN_H_
15 #include "wx/object.h"
16 #include "wx/variant.h"
18 typedef void WXIDISPATCH
;
19 typedef unsigned short* WXBSTR
;
27 * Wraps up an IDispatch pointer and invocation; does variant conversion.
30 class WXDLLEXPORT wxAutomationObject
: public wxObject
33 wxAutomationObject(WXIDISPATCH
* dispatchPtr
= NULL
);
34 virtual ~wxAutomationObject();
36 // Set/get dispatch pointer
37 inline void SetDispatchPtr(WXIDISPATCH
* dispatchPtr
) { m_dispatchPtr
= dispatchPtr
; };
38 inline WXIDISPATCH
* GetDispatchPtr() const { return m_dispatchPtr
; }
40 // Get a dispatch pointer from the current object associated
41 // with a class id, such as "Excel.Application"
42 bool GetInstance(const wxString
& classId
) const;
44 // Get a dispatch pointer from a new instance of the the class
45 bool CreateInstance(const wxString
& classId
) const;
47 // Low-level invocation function. Pass either an array of variants,
48 // or an array of pointers to variants.
49 bool Invoke(const wxString
& member
, int action
,
50 wxVariant
& retValue
, int noArgs
, wxVariant args
[], const wxVariant
* ptrArgs
[] = 0) const;
52 // Invoke a member function
53 wxVariant
CallMethod(const wxString
& method
, int noArgs
, wxVariant args
[]);
54 wxVariant
CallMethodArray(const wxString
& method
, int noArgs
, const wxVariant
**args
);
56 // Convenience function
57 wxVariant
CallMethod(const wxString
& method
,
58 const wxVariant
& arg1
= wxNullVariant
, const wxVariant
& arg2
= wxNullVariant
,
59 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
60 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
63 wxVariant
GetProperty(const wxString
& property
, int noArgs
= 0, wxVariant args
[] = (wxVariant
*) NULL
) const;
64 wxVariant
GetPropertyArray(const wxString
& property
, int noArgs
, const wxVariant
**args
) const;
65 wxVariant
GetProperty(const wxString
& property
,
66 const wxVariant
& arg1
, const wxVariant
& arg2
= wxNullVariant
,
67 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
68 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
70 bool PutPropertyArray(const wxString
& property
, int noArgs
, const wxVariant
**args
);
71 bool PutProperty(const wxString
& property
, int noArgs
, wxVariant args
[]) ;
72 bool PutProperty(const wxString
& property
,
73 const wxVariant
& arg1
, const wxVariant
& arg2
= wxNullVariant
,
74 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
75 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
77 // Uses DISPATCH_PROPERTYGET
78 // and returns a dispatch pointer. The calling code should call Release
79 // on the pointer, though this could be implicit by constructing an wxAutomationObject
80 // with it and letting the destructor call Release.
81 WXIDISPATCH
* GetDispatchProperty(const wxString
& property
, int noArgs
, wxVariant args
[]) const;
82 WXIDISPATCH
* GetDispatchProperty(const wxString
& property
, int noArgs
, const wxVariant
**args
) const;
84 // A way of initialising another wxAutomationObject with a dispatch object,
85 // without having to deal with nasty IDispatch pointers.
86 bool GetObject(wxAutomationObject
& obj
, const wxString
& property
, int noArgs
= 0, wxVariant args
[] = (wxVariant
*) NULL
) const;
87 bool GetObject(wxAutomationObject
& obj
, const wxString
& property
, int noArgs
, const wxVariant
**args
) const;
90 WXIDISPATCH
* m_dispatchPtr
;
92 DECLARE_NO_COPY_CLASS(wxAutomationObject
)