]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/ole/automtn.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / msw / ole / automtn.h
CommitLineData
e8b6d59d 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/msw/ole/automtn.h
e8b6d59d
JS
3// Purpose: OLE automation utilities
4// Author: Julian Smart
5// Modified by:
6// Created: 11/6/98
e8b6d59d 7// Copyright: (c) 1998, Julian Smart
65571936 8// Licence: wxWindows licence
e8b6d59d
JS
9/////////////////////////////////////////////////////////////////////////////
10
e8b6d59d
JS
11#ifndef _WX_AUTOMTN_H_
12#define _WX_AUTOMTN_H_
13
ca5c6ac3
VZ
14#include "wx/defs.h"
15
16#if wxUSE_OLE_AUTOMATION
17
e8b6d59d
JS
18#include "wx/object.h"
19#include "wx/variant.h"
20
21typedef void WXIDISPATCH;
22typedef unsigned short* WXBSTR;
03a1d863 23typedef unsigned long WXLCID;
e8b6d59d 24
89c684ef
JS
25#ifdef GetObject
26#undef GetObject
27#endif
28
6eefca4f
VZ
29// Flags used with wxAutomationObject::GetInstance()
30enum wxAutomationInstanceFlags
31{
32 // Only use the existing instance, never create a new one.
33 wxAutomationInstance_UseExistingOnly = 0,
34
35 // Create a new instance if there are no existing ones.
1244d2e0
VZ
36 wxAutomationInstance_CreateIfNeeded = 1,
37
38 // Do not log errors if we failed to get the existing instance because none
39 // is available.
40 wxAutomationInstance_SilentIfNone = 2
6eefca4f
VZ
41};
42
e8b6d59d
JS
43/*
44 * wxAutomationObject
45 * Wraps up an IDispatch pointer and invocation; does variant conversion.
46 */
47
53a2db12 48class WXDLLIMPEXP_CORE wxAutomationObject: public wxObject
e8b6d59d
JS
49{
50public:
51 wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL);
d3c7fc99 52 virtual ~wxAutomationObject();
e8b6d59d 53
0a0e6a5b 54 // Set/get dispatch pointer
bb24f84b
VZ
55 void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; }
56 WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; }
57 bool IsOk() const { return m_dispatchPtr != NULL; }
e8b6d59d 58
0a0e6a5b 59 // Get a dispatch pointer from the current object associated
27d76879 60 // with a ProgID, such as "Excel.Application"
6eefca4f
VZ
61 bool GetInstance(const wxString& progId,
62 int flags = wxAutomationInstance_CreateIfNeeded) const;
e8b6d59d 63
6eefca4f 64 // Get a dispatch pointer from a new instance of the class
27d76879 65 bool CreateInstance(const wxString& progId) const;
e8b6d59d 66
0a0e6a5b
WS
67 // Low-level invocation function. Pass either an array of variants,
68 // or an array of pointers to variants.
e8b6d59d
JS
69 bool Invoke(const wxString& member, int action,
70 wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = 0) const;
71
0a0e6a5b
WS
72 // Invoke a member function
73 wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]);
74 wxVariant CallMethodArray(const wxString& method, int noArgs, const wxVariant **args);
e8b6d59d 75
0a0e6a5b
WS
76 // Convenience function
77 wxVariant CallMethod(const wxString& method,
78 const wxVariant& arg1 = wxNullVariant, const wxVariant& arg2 = wxNullVariant,
79 const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
80 const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
e8b6d59d 81
0a0e6a5b 82 // Get/Put property
d3b9f782 83 wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const;
0a0e6a5b
WS
84 wxVariant GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const;
85 wxVariant GetProperty(const wxString& property,
86 const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
87 const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
88 const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
e8b6d59d 89
c55fd2c6 90 bool PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args);
e8b6d59d 91 bool PutProperty(const wxString& property, int noArgs, wxVariant args[]) ;
0a0e6a5b
WS
92 bool PutProperty(const wxString& property,
93 const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
94 const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
95 const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
96
97 // Uses DISPATCH_PROPERTYGET
98 // and returns a dispatch pointer. The calling code should call Release
99 // on the pointer, though this could be implicit by constructing an wxAutomationObject
100 // with it and letting the destructor call Release.
e8b6d59d 101 WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, wxVariant args[]) const;
24f4ad95 102 WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const;
e8b6d59d 103
0a0e6a5b
WS
104 // A way of initialising another wxAutomationObject with a dispatch object,
105 // without having to deal with nasty IDispatch pointers.
d3b9f782 106 bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const;
0a0e6a5b 107 bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const;
e8b6d59d 108
f239af65
VZ
109 // Returns the locale identifier used in automation calls. The default is
110 // LOCALE_SYSTEM_DEFAULT. Objects obtained by GetObject() inherit the
111 // locale identifier from the one that created them.
03a1d863 112 WXLCID GetLCID() const;
f239af65
VZ
113
114 // Sets the locale identifier to be used in automation calls performed by
115 // this object. The default is LOCALE_SYSTEM_DEFAULT.
03a1d863 116 void SetLCID(WXLCID lcid);
f239af65
VZ
117
118public: // public for compatibility only, don't use m_dispatchPtr directly.
e8b6d59d 119 WXIDISPATCH* m_dispatchPtr;
22f3361e 120
f239af65 121private:
03a1d863 122 WXLCID m_lcid;
f239af65 123
c0c133e1 124 wxDECLARE_NO_COPY_CLASS(wxAutomationObject);
e8b6d59d
JS
125};
126
ca5c6ac3 127#endif // wxUSE_OLE_AUTOMATION
e8b6d59d 128
ca5c6ac3 129#endif // _WX_AUTOMTN_H_