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
[]);
58 wxVariant
CallMethodArray(const wxString
& method
, int noArgs
, const wxVariant
**args
);
60 // Convenience function
61 wxVariant
CallMethod(const wxString
& method
,
62 const wxVariant
& arg1
= wxNullVariant
, const wxVariant
& arg2
= wxNullVariant
,
63 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
64 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
67 wxVariant
GetProperty(const wxString
& property
, int noArgs
= 0, wxVariant args
[] = (wxVariant
*) NULL
) const;
68 wxVariant
GetPropertyArray(const wxString
& property
, int noArgs
, const wxVariant
**args
) const;
69 wxVariant
GetProperty(const wxString
& property
,
70 const wxVariant
& arg1
, const wxVariant
& arg2
= wxNullVariant
,
71 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
72 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
74 bool PutPropertyArray(const wxString
& property
, int noArgs
, const wxVariant
**args
);
75 bool PutProperty(const wxString
& property
, int noArgs
, wxVariant args
[]) ;
76 bool PutProperty(const wxString
& property
,
77 const wxVariant
& arg1
, const wxVariant
& arg2
= wxNullVariant
,
78 const wxVariant
& arg3
= wxNullVariant
, const wxVariant
& arg4
= wxNullVariant
,
79 const wxVariant
& arg5
= wxNullVariant
, const wxVariant
& arg6
= wxNullVariant
);
81 // Uses DISPATCH_PROPERTYGET
82 // and returns a dispatch pointer. The calling code should call Release
83 // on the pointer, though this could be implicit by constructing an wxAutomationObject
84 // with it and letting the destructor call Release.
85 WXIDISPATCH
* GetDispatchProperty(const wxString
& property
, int noArgs
, wxVariant args
[]) const;
86 WXIDISPATCH
* GetDispatchProperty(const wxString
& property
, int noArgs
, const wxVariant
**args
) const;
88 // A way of initialising another wxAutomationObject with a dispatch object,
89 // without having to deal with nasty IDispatch pointers.
90 bool GetObject(wxAutomationObject
& obj
, const wxString
& property
, int noArgs
= 0, wxVariant args
[] = (wxVariant
*) NULL
) const;
91 bool GetObject(wxAutomationObject
& obj
, const wxString
& property
, int noArgs
, const wxVariant
**args
) const;
94 WXIDISPATCH
* m_dispatchPtr
;