]>
Commit | Line | Data |
---|---|---|
e8b6d59d JS |
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 | |
65571936 | 9 | // Licence: wxWindows licence |
e8b6d59d JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12028905 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
e8b6d59d JS |
13 | #pragma interface "automtn.h" |
14 | #endif | |
15 | ||
16 | #ifndef _WX_AUTOMTN_H_ | |
17 | #define _WX_AUTOMTN_H_ | |
18 | ||
19 | #include "wx/object.h" | |
20 | #include "wx/variant.h" | |
21 | ||
22 | typedef void WXIDISPATCH; | |
23 | typedef unsigned short* WXBSTR; | |
24 | ||
89c684ef JS |
25 | #ifdef GetObject |
26 | #undef GetObject | |
27 | #endif | |
28 | ||
e8b6d59d JS |
29 | /* |
30 | * wxAutomationObject | |
31 | * Wraps up an IDispatch pointer and invocation; does variant conversion. | |
32 | */ | |
33 | ||
8853b9a8 | 34 | class WXDLLEXPORT wxAutomationObject: public wxObject |
e8b6d59d JS |
35 | { |
36 | public: | |
37 | wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL); | |
38 | ~wxAutomationObject(); | |
39 | ||
0a0e6a5b | 40 | // Set/get dispatch pointer |
e8b6d59d JS |
41 | inline void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; }; |
42 | inline WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; } | |
43 | ||
0a0e6a5b WS |
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; | |
e8b6d59d | 47 | |
0a0e6a5b WS |
48 | // Get a dispatch pointer from a new instance of the the class |
49 | bool CreateInstance(const wxString& classId) const; | |
e8b6d59d | 50 | |
0a0e6a5b WS |
51 | // Low-level invocation function. Pass either an array of variants, |
52 | // or an array of pointers to variants. | |
e8b6d59d JS |
53 | bool Invoke(const wxString& member, int action, |
54 | wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = 0) const; | |
55 | ||
0a0e6a5b WS |
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); | |
e8b6d59d | 59 | |
0a0e6a5b WS |
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); | |
e8b6d59d | 65 | |
0a0e6a5b | 66 | // Get/Put property |
e8b6d59d | 67 | wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = (wxVariant*) NULL) const; |
0a0e6a5b WS |
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); | |
e8b6d59d | 73 | |
c55fd2c6 | 74 | bool PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args); |
e8b6d59d | 75 | bool PutProperty(const wxString& property, int noArgs, wxVariant args[]) ; |
0a0e6a5b WS |
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); | |
80 | ||
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. | |
e8b6d59d | 85 | WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, wxVariant args[]) const; |
24f4ad95 | 86 | WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const; |
e8b6d59d | 87 | |
0a0e6a5b WS |
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; | |
e8b6d59d | 92 | |
e8b6d59d JS |
93 | public: |
94 | WXIDISPATCH* m_dispatchPtr; | |
22f3361e VZ |
95 | |
96 | DECLARE_NO_COPY_CLASS(wxAutomationObject) | |
e8b6d59d JS |
97 | }; |
98 | ||
e8b6d59d JS |
99 | |
100 | #endif | |
101 | // _WX_AUTOMTN_H_ |