]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/ole/automtn.h
allow passing temporary functors to Bind() too (closes #10653)
[wxWidgets.git] / include / wx / msw / ole / automtn.h
CommitLineData
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
e8b6d59d
JS
12#ifndef _WX_AUTOMTN_H_
13#define _WX_AUTOMTN_H_
14
ca5c6ac3
VZ
15#include "wx/defs.h"
16
17#if wxUSE_OLE_AUTOMATION
18
e8b6d59d
JS
19#include "wx/object.h"
20#include "wx/variant.h"
21
22typedef void WXIDISPATCH;
23typedef 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
53a2db12 34class WXDLLIMPEXP_CORE wxAutomationObject: public wxObject
e8b6d59d
JS
35{
36public:
37 wxAutomationObject(WXIDISPATCH* dispatchPtr = NULL);
d3c7fc99 38 virtual ~wxAutomationObject();
e8b6d59d 39
0a0e6a5b 40 // Set/get dispatch pointer
bb24f84b
VZ
41 void SetDispatchPtr(WXIDISPATCH* dispatchPtr) { m_dispatchPtr = dispatchPtr; }
42 WXIDISPATCH* GetDispatchPtr() const { return m_dispatchPtr; }
43 bool IsOk() const { return m_dispatchPtr != NULL; }
e8b6d59d 44
0a0e6a5b
WS
45 // Get a dispatch pointer from the current object associated
46 // with a class id, such as "Excel.Application"
47 bool GetInstance(const wxString& classId) const;
e8b6d59d 48
0a0e6a5b
WS
49 // Get a dispatch pointer from a new instance of the the class
50 bool CreateInstance(const wxString& classId) const;
e8b6d59d 51
0a0e6a5b
WS
52 // Low-level invocation function. Pass either an array of variants,
53 // or an array of pointers to variants.
e8b6d59d
JS
54 bool Invoke(const wxString& member, int action,
55 wxVariant& retValue, int noArgs, wxVariant args[], const wxVariant* ptrArgs[] = 0) const;
56
0a0e6a5b
WS
57 // Invoke a member function
58 wxVariant CallMethod(const wxString& method, int noArgs, wxVariant args[]);
59 wxVariant CallMethodArray(const wxString& method, int noArgs, const wxVariant **args);
e8b6d59d 60
0a0e6a5b
WS
61 // Convenience function
62 wxVariant CallMethod(const wxString& method,
63 const wxVariant& arg1 = wxNullVariant, const wxVariant& arg2 = wxNullVariant,
64 const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
65 const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
e8b6d59d 66
0a0e6a5b 67 // Get/Put property
d3b9f782 68 wxVariant GetProperty(const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const;
0a0e6a5b
WS
69 wxVariant GetPropertyArray(const wxString& property, int noArgs, const wxVariant **args) const;
70 wxVariant GetProperty(const wxString& property,
71 const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
72 const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
73 const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
e8b6d59d 74
c55fd2c6 75 bool PutPropertyArray(const wxString& property, int noArgs, const wxVariant **args);
e8b6d59d 76 bool PutProperty(const wxString& property, int noArgs, wxVariant args[]) ;
0a0e6a5b
WS
77 bool PutProperty(const wxString& property,
78 const wxVariant& arg1, const wxVariant& arg2 = wxNullVariant,
79 const wxVariant& arg3 = wxNullVariant, const wxVariant& arg4 = wxNullVariant,
80 const wxVariant& arg5 = wxNullVariant, const wxVariant& arg6 = wxNullVariant);
81
82 // Uses DISPATCH_PROPERTYGET
83 // and returns a dispatch pointer. The calling code should call Release
84 // on the pointer, though this could be implicit by constructing an wxAutomationObject
85 // with it and letting the destructor call Release.
e8b6d59d 86 WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, wxVariant args[]) const;
24f4ad95 87 WXIDISPATCH* GetDispatchProperty(const wxString& property, int noArgs, const wxVariant **args) const;
e8b6d59d 88
0a0e6a5b
WS
89 // A way of initialising another wxAutomationObject with a dispatch object,
90 // without having to deal with nasty IDispatch pointers.
d3b9f782 91 bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs = 0, wxVariant args[] = NULL) const;
0a0e6a5b 92 bool GetObject(wxAutomationObject& obj, const wxString& property, int noArgs, const wxVariant **args) const;
e8b6d59d 93
e8b6d59d
JS
94public:
95 WXIDISPATCH* m_dispatchPtr;
22f3361e 96
c0c133e1 97 wxDECLARE_NO_COPY_CLASS(wxAutomationObject);
e8b6d59d
JS
98};
99
ca5c6ac3 100#endif // wxUSE_OLE_AUTOMATION
e8b6d59d 101
ca5c6ac3 102#endif // _WX_AUTOMTN_H_