]>
Commit | Line | Data |
---|---|---|
bf354396 | 1 | /////////////////////////////////////////////////////////////////////////////// |
0ed94e83 | 2 | // Name: wx/msw/ole/activex.h |
bf354396 VZ |
3 | // Purpose: wxActiveXContainer class |
4 | // Author: Ryan Norton <wxprojects@comcast.net> | |
5 | // Modified by: | |
6 | // Created: 8/18/05 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Ryan Norton | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // Definitions | |
14 | // ============================================================================ | |
15 | ||
16 | #ifndef _WX_MSW_OLE_ACTIVEXCONTAINER_H_ | |
17 | #define _WX_MSW_OLE_ACTIVEXCONTAINER_H_ | |
18 | ||
19 | //--------------------------------------------------------------------------- | |
20 | // COM includes | |
21 | //--------------------------------------------------------------------------- | |
22 | #include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc. | |
23 | #include "wx/msw/ole/uuid.h" //IID etc.. | |
24 | ||
25 | //--------------------------------------------------------------------------- | |
26 | // COM compatability definitions | |
27 | //--------------------------------------------------------------------------- | |
28 | #ifndef STDMETHODCALLTYPE | |
29 | #define STDMETHODCALLTYPE __stdcall | |
30 | #endif | |
31 | #ifndef STDMETHOD | |
32 | #define STDMETHOD(funcname) virtual HRESULT STDMETHODCALLTYPE funcname | |
33 | #endif | |
34 | #ifndef PURE | |
35 | #define PURE = 0 | |
36 | #endif | |
37 | #ifndef __RPC_FAR | |
38 | #define __RPC_FAR FAR | |
39 | #endif | |
40 | ||
41 | //--------------------------------------------------------------------------- | |
42 | // WX includes | |
43 | //--------------------------------------------------------------------------- | |
44 | #include "wx/window.h" | |
45 | ||
46 | //--------------------------------------------------------------------------- | |
47 | // MSW COM includes | |
48 | //--------------------------------------------------------------------------- | |
49 | #include <oleidl.h> | |
50 | #include <olectl.h> | |
0ed94e83 WS |
51 | |
52 | #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__) | |
bf354396 | 53 | #include <exdisp.h> |
0ed94e83 WS |
54 | #endif |
55 | ||
bf354396 VZ |
56 | #include <docobj.h> |
57 | ||
58 | // | |
59 | // These defines are from another ole header - but its not in the | |
60 | // latest sdk. Also the ifndef DISPID_READYSTATE is here because at | |
61 | // least on my machine with the latest sdk olectl.h defines these 3 | |
62 | // | |
63 | #ifndef DISPID_READYSTATE | |
64 | #define DISPID_READYSTATE -525 | |
65 | #define DISPID_READYSTATECHANGE -609 | |
66 | #define DISPID_AMBIENT_TRANSFERPRIORITY -728 | |
67 | #endif | |
68 | ||
69 | #define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED -5501 | |
70 | #define DISPID_AMBIENT_SILENT -5502 | |
71 | ||
72 | #ifndef DISPID_AMBIENT_CODEPAGE | |
73 | # define DISPID_AMBIENT_CODEPAGE -725 | |
74 | # define DISPID_AMBIENT_CHARSET -727 | |
75 | #endif | |
76 | ||
77 | ||
78 | //--------------------------------------------------------------------------- | |
79 | // | |
80 | // wxActiveXContainer | |
81 | // | |
82 | //--------------------------------------------------------------------------- | |
83 | ||
84 | #define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \ | |
85 | class wxAutoOleInterface \ | |
86 | { \ | |
87 | protected: \ | |
88 | I *m_interface; \ | |
89 | \ | |
90 | public: \ | |
91 | explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \ | |
92 | wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \ | |
93 | { QueryInterface(riid, pUnk); } \ | |
94 | wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \ | |
95 | { QueryInterface(riid, pDispatch); } \ | |
96 | wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\ | |
97 | { CreateInstance(clsid, riid); }\ | |
98 | wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\ | |
99 | { operator = (ti); }\ | |
100 | \ | |
101 | wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\ | |
102 | {\ | |
103 | if (ti.m_interface)\ | |
104 | ti.m_interface->AddRef();\ | |
105 | Free();\ | |
106 | m_interface = ti.m_interface;\ | |
107 | return *this;\ | |
108 | }\ | |
109 | \ | |
110 | wxAutoOleInterface& operator = (I *&ti)\ | |
111 | {\ | |
112 | Free();\ | |
113 | m_interface = ti;\ | |
114 | return *this;\ | |
115 | }\ | |
116 | \ | |
117 | ~wxAutoOleInterface() { Free(); }\ | |
118 | \ | |
119 | inline void Free()\ | |
120 | {\ | |
121 | if (m_interface)\ | |
122 | m_interface->Release();\ | |
123 | m_interface = NULL;\ | |
124 | }\ | |
125 | \ | |
126 | HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\ | |
127 | {\ | |
128 | Free();\ | |
129 | wxASSERT(pUnk != NULL);\ | |
130 | return pUnk->QueryInterface(riid, (void **) &m_interface);\ | |
131 | }\ | |
132 | \ | |
133 | HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\ | |
134 | {\ | |
135 | Free();\ | |
136 | return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\ | |
137 | }\ | |
138 | \ | |
139 | inline operator I *() const {return m_interface;}\ | |
140 | inline I* operator ->() {return m_interface;}\ | |
141 | inline I** GetRef() {return &m_interface;}\ | |
142 | inline bool Ok() const {return m_interface != NULL;}\ | |
143 | }; | |
144 | ||
145 | WX_DECLARE_AUTOOLE(wxAutoIDispatch, IDispatch) | |
146 | WX_DECLARE_AUTOOLE(wxAutoIOleClientSite, IOleClientSite) | |
147 | WX_DECLARE_AUTOOLE(wxAutoIUnknown, IUnknown) | |
148 | WX_DECLARE_AUTOOLE(wxAutoIOleObject, IOleObject) | |
149 | WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject, IOleInPlaceObject) | |
150 | WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject, IOleInPlaceActiveObject) | |
151 | WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView, IOleDocumentView) | |
152 | WX_DECLARE_AUTOOLE(wxAutoIViewObject, IViewObject) | |
153 | WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceSite, IOleInPlaceSite) | |
154 | WX_DECLARE_AUTOOLE(wxAutoIOleDocument, IOleDocument) | |
155 | WX_DECLARE_AUTOOLE(wxAutoIPersistStreamInit, IPersistStreamInit) | |
156 | WX_DECLARE_AUTOOLE(wxAutoIAdviseSink, IAdviseSink) | |
157 | ||
158 | class wxActiveXContainer : public wxWindow | |
159 | { | |
160 | public: | |
161 | wxActiveXContainer(wxWindow * parent, REFIID iid, IUnknown* pUnk); | |
162 | virtual ~wxActiveXContainer(); | |
163 | ||
164 | void OnSize(wxSizeEvent&); | |
165 | void OnPaint(wxPaintEvent&); | |
166 | void OnSetFocus(wxFocusEvent&); | |
167 | void OnKillFocus(wxFocusEvent&); | |
168 | ||
169 | protected: | |
170 | friend class FrameSite; | |
171 | ||
172 | wxAutoIDispatch m_Dispatch; | |
173 | wxAutoIOleClientSite m_clientSite; | |
174 | wxAutoIUnknown m_ActiveX; | |
175 | wxAutoIOleObject m_oleObject; | |
176 | wxAutoIOleInPlaceObject m_oleInPlaceObject; | |
177 | wxAutoIOleInPlaceActiveObject m_oleInPlaceActiveObject; | |
178 | wxAutoIOleDocumentView m_docView; | |
179 | wxAutoIViewObject m_viewObject; | |
180 | HWND m_oleObjectHWND; | |
181 | bool m_bAmbientUserMode; | |
182 | DWORD m_docAdviseCookie; | |
183 | wxWindow* m_realparent; | |
184 | ||
185 | void CreateActiveX(REFIID, IUnknown*); | |
186 | }; | |
187 | ||
188 | #endif // _WX_MSW_OLE_ACTIVEXCONTAINER_H_ |