]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/ole/automtn.h
Further wxAUI commits
[wxWidgets.git] / include / wx / msw / ole / automtn.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: automtn.h
3 // Purpose: OLE automation utilities
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 11/6/98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998, Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_AUTOMTN_H_
13 #define _WX_AUTOMTN_H_
14
15 #include "wx/object.h"
16 #include "wx/variant.h"
17
18 typedef void WXIDISPATCH;
19 typedef unsigned short* WXBSTR;
20
21 #ifdef GetObject
22 #undef GetObject
23 #endif
24
25 /*
26 * wxAutomationObject
27 * Wraps up an IDispatch pointer and invocation; does variant conversion.
28 */
29
30 class WXDLLEXPORT wxAutomationObject: public wxObject
31 {
32 public:
33 wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL);
34 ~wxAutomationObject();
35
36 // Set/get dispatch pointer
37 inline void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; };
38 inline WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; }
39
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;
43
44 // Get a dispatch pointer from a new instance of the the class
45 bool CreateInstance(const wxString& classId) const;
46
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;
51
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);
55
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);
61
62 // Get/Put property
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);
69
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);
76
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;
83
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;
88
89 public:
90 WXIDISPATCH* m_dispatchPtr;
91
92 DECLARE_NO_COPY_CLASS(wxAutomationObject)
93 };
94
95
96 #endif
97 // _WX_AUTOMTN_H_