]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/ole/automtn.h
Compile fixes for samples and dialoged,
[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 #ifdef __GNUG__
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
25 #ifdef GetObject
26 #undef GetObject
27 #endif
28
29 /*
30 * wxAutomationObject
31 * Wraps up an IDispatch pointer and invocation; does variant conversion.
32 */
33
34 class WXDLLEXPORT wxAutomationObject: public wxObject
35 {
36 public:
37 wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL);
38 ~wxAutomationObject();
39
40 // Set/get dispatch pointer
41 inline void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; };
42 inline WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; }
43
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;
47
48 // Get a dispatch pointer from a new instance of the the class
49 bool CreateInstance(const wxString& classId) const;
50
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;
55
56 // Invoke a member function
57 wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]);
58
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);
64
65 // Get/Put property
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);
71
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);
77
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;
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
88 public:
89 WXIDISPATCH* m_dispatchPtr;
90 };
91
92
93 #endif
94 // _WX_AUTOMTN_H_