1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/ole/activex.h
3 // Purpose: wxActiveXContainer class
4 // Author: Ryan Norton <wxprojects@comcast.net>
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 #ifndef _WX_MSW_OLE_ACTIVEXCONTAINER_H_
17 #define _WX_MSW_OLE_ACTIVEXCONTAINER_H_
19 //---------------------------------------------------------------------------
21 //---------------------------------------------------------------------------
22 #include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc.
23 #include "wx/msw/ole/uuid.h" //IID etc..
25 //---------------------------------------------------------------------------
26 // COM compatability definitions
27 //---------------------------------------------------------------------------
28 #ifndef STDMETHODCALLTYPE
29 #define STDMETHODCALLTYPE __stdcall
32 #define STDMETHOD(funcname) virtual HRESULT STDMETHODCALLTYPE funcname
41 //---------------------------------------------------------------------------
43 //---------------------------------------------------------------------------
44 #include "wx/window.h"
45 #include "wx/variant.h"
47 //---------------------------------------------------------------------------
49 //---------------------------------------------------------------------------
53 #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
60 // These defines are from another ole header - but its not in the
61 // latest sdk. Also the ifndef DISPID_READYSTATE is here because at
62 // least on my machine with the latest sdk olectl.h defines these 3
64 #ifndef DISPID_READYSTATE
65 #define DISPID_READYSTATE -525
66 #define DISPID_READYSTATECHANGE -609
67 #define DISPID_AMBIENT_TRANSFERPRIORITY -728
70 #define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED -5501
71 #define DISPID_AMBIENT_SILENT -5502
73 #ifndef DISPID_AMBIENT_CODEPAGE
74 # define DISPID_AMBIENT_CODEPAGE -725
75 # define DISPID_AMBIENT_CHARSET -727
79 //---------------------------------------------------------------------------
83 //---------------------------------------------------------------------------
85 #define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \
86 class wxAutoOleInterface \
92 explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \
93 wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \
94 { QueryInterface(riid, pUnk); } \
95 wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \
96 { QueryInterface(riid, pDispatch); } \
97 wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\
98 { CreateInstance(clsid, riid); }\
99 wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\
100 { operator = (ti); }\
102 wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\
105 ti.m_interface->AddRef();\
107 m_interface = ti.m_interface;\
111 wxAutoOleInterface& operator = (I *&ti)\
118 ~wxAutoOleInterface() { Free(); }\
123 m_interface->Release();\
127 HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\
130 wxASSERT(pUnk != NULL);\
131 return pUnk->QueryInterface(riid, (void **) &m_interface);\
134 HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\
137 return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\
140 inline operator I *() const {return m_interface;}\
141 inline I* operator ->() {return m_interface;}\
142 inline I** GetRef() {return &m_interface;}\
143 inline bool Ok() const {return m_interface != NULL;}\
146 WX_DECLARE_AUTOOLE(wxAutoIDispatch
, IDispatch
)
147 WX_DECLARE_AUTOOLE(wxAutoIOleClientSite
, IOleClientSite
)
148 WX_DECLARE_AUTOOLE(wxAutoIUnknown
, IUnknown
)
149 WX_DECLARE_AUTOOLE(wxAutoIOleObject
, IOleObject
)
150 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject
, IOleInPlaceObject
)
151 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject
, IOleInPlaceActiveObject
)
152 WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView
, IOleDocumentView
)
153 WX_DECLARE_AUTOOLE(wxAutoIViewObject
, IViewObject
)
155 class wxActiveXContainer
: public wxWindow
158 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);
159 virtual ~wxActiveXContainer();
161 void OnSize(wxSizeEvent
&);
162 void OnPaint(wxPaintEvent
&);
163 void OnSetFocus(wxFocusEvent
&);
164 void OnKillFocus(wxFocusEvent
&);
167 friend class FrameSite
;
168 friend class wxActiveXEvents
;
170 wxAutoIDispatch m_Dispatch
;
171 wxAutoIOleClientSite m_clientSite
;
172 wxAutoIUnknown m_ActiveX
;
173 wxAutoIOleObject m_oleObject
;
174 wxAutoIOleInPlaceObject m_oleInPlaceObject
;
175 wxAutoIOleInPlaceActiveObject m_oleInPlaceActiveObject
;
176 wxAutoIOleDocumentView m_docView
;
177 wxAutoIViewObject m_viewObject
;
178 HWND m_oleObjectHWND
;
179 bool m_bAmbientUserMode
;
180 DWORD m_docAdviseCookie
;
181 wxWindow
* m_realparent
;
183 void CreateActiveX(REFIID
, IUnknown
*);
188 class wxActiveXEvent
: public wxCommandEvent
191 friend class wxActiveXEvents
;
196 virtual wxEvent
*Clone() const
197 { return new wxActiveXEvent(*this); }
199 size_t ParamCount() const
200 { return m_params
.GetCount(); }
202 wxString
ParamType(size_t idx
) const
204 wxASSERT(idx
< m_params
.GetCount());
205 return m_params
[idx
].GetType();
208 wxString
ParamName(size_t idx
) const
210 wxASSERT(idx
< m_params
.GetCount());
211 return m_params
[idx
].GetName();
214 wxVariant
& operator[] (size_t idx
)
216 wxASSERT(idx
< ParamCount());
217 return m_params
[idx
];
220 DISPID
GetDispatchId() const
224 #define wxACTIVEX_ID 14001
225 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA
, wxEVT_ACTIVEX
, wxACTIVEX_ID
)
226 typedef void (wxEvtHandler::*wxActiveXEventFunction
)(wxActiveXEvent
&);
227 #define EVT_ACTIVEX(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_ACTIVEX, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxActiveXEventFunction) & fn, (wxObject *) NULL ),
228 #define wxActiveXEventHandler(func) \
229 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxActiveXEventFunction, &func)
231 #endif // _WX_MSW_OLE_ACTIVEXCONTAINER_H_