1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: OLE automation utilities
4 // Author: Julian Smart
8 // Copyright: (c) 1998, Julian Smart
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma interface "automtn.h"
16 #ifndef _WX_AUTOMTN_H_
17 #define _WX_AUTOMTN_H_
19 #include "wx/object.h"
20 #include "wx/variant.h"
22 typedef void WXIDISPATCH
;
23 typedef unsigned short* WXBSTR
;
31 * Wraps up an IDispatch pointer and invocation; does variant conversion.
34 class WXDLLEXPORT wxAutomationObject
: public wxObject
37 wxAutomationObject(WXIDISPATCH
* dispatchPtr
= NULL
);
38 ~wxAutomationObject();
40 // Set/get dispatch pointer
41 inline void SetDispatchPtr(WXIDISPATCH
* dispatchPtr
) { m_dispatchPtr
= dispatchPtr
; };
42 inline WXIDISPATCH
* GetDispatchPtr() const { return m_dispatchPtr
; }
44 // Get a dispatch pointer from the current object associated
45 // with a class id, such as "Excel.Application"
46 bool GetInstance(const wxString
& classId
) const;
48 // Get a dispatch pointer from a new instance of the the class
49 bool CreateInstance(const wxString
& classId
) const;
51 // Low-level invocation function. Pass either an array of variants,
52 // or an array of pointers to variants.
53 bool Invoke(const wxString
& member
, int action
,
54 wxVariant
& retValue
, int noArgs
, wxVariant args
[], const wxVariant
* ptrArgs
[] = 0) const;
56 // Invoke a member function
57 wxVariant
CallMethod(const wxString
& method
, int noArgs
, wxVariant args
[]);
59 // Convenience function
60 wxVariant
CallMethod(const wxString
& method
,
61 const wxVariant
& arg1
= wxNullVariant
, const wxVariant
& arg2
= wxNullVariant
,
62 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
63 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
66 wxVariant
GetProperty(const wxString
& property
, int noArgs
= 0, wxVariant args
[] = (wxVariant
*) NULL
) const;
67 wxVariant
GetProperty(const wxString
& property
,
68 const wxVariant
& arg1
, const wxVariant
& arg2
= wxNullVariant
,
69 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
70 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
72 bool PutProperty(const wxString
& property
, int noArgs
, wxVariant args
[]) ;
73 bool PutProperty(const wxString
& property
,
74 const wxVariant
& arg1
, const wxVariant
& arg2
= wxNullVariant
,
75 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
76 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
78 // Uses DISPATCH_PROPERTYGET
79 // and returns a dispatch pointer. The calling code should call Release
80 // on the pointer, though this could be implicit by constructing an wxAutomationObject
81 // with it and letting the destructor call Release.
82 WXIDISPATCH
* GetDispatchProperty(const wxString
& property
, int noArgs
, 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;
89 WXIDISPATCH
* m_dispatchPtr
;