1 ///////////////////////////////////////////////////////////////////////////////
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"
46 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
55 // These defines are from another ole header - but its not in the
56 // latest sdk. Also the ifndef DISPID_READYSTATE is here because at
57 // least on my machine with the latest sdk olectl.h defines these 3
59 #ifndef DISPID_READYSTATE
60 #define DISPID_READYSTATE -525
61 #define DISPID_READYSTATECHANGE -609
62 #define DISPID_AMBIENT_TRANSFERPRIORITY -728
65 #define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED -5501
66 #define DISPID_AMBIENT_SILENT -5502
68 #ifndef DISPID_AMBIENT_CODEPAGE
69 # define DISPID_AMBIENT_CODEPAGE -725
70 # define DISPID_AMBIENT_CHARSET -727
74 //---------------------------------------------------------------------------
78 //---------------------------------------------------------------------------
80 #define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \
81 class wxAutoOleInterface \
87 explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \
88 wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \
89 { QueryInterface(riid, pUnk); } \
90 wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \
91 { QueryInterface(riid, pDispatch); } \
92 wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\
93 { CreateInstance(clsid, riid); }\
94 wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\
97 wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\
100 ti.m_interface->AddRef();\
102 m_interface = ti.m_interface;\
106 wxAutoOleInterface& operator = (I *&ti)\
113 ~wxAutoOleInterface() { Free(); }\
118 m_interface->Release();\
122 HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\
125 wxASSERT(pUnk != NULL);\
126 return pUnk->QueryInterface(riid, (void **) &m_interface);\
129 HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\
132 return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\
135 inline operator I *() const {return m_interface;}\
136 inline I* operator ->() {return m_interface;}\
137 inline I** GetRef() {return &m_interface;}\
138 inline bool Ok() const {return m_interface != NULL;}\
141 WX_DECLARE_AUTOOLE(wxAutoIDispatch
, IDispatch
)
142 WX_DECLARE_AUTOOLE(wxAutoIOleClientSite
, IOleClientSite
)
143 WX_DECLARE_AUTOOLE(wxAutoIUnknown
, IUnknown
)
144 WX_DECLARE_AUTOOLE(wxAutoIOleObject
, IOleObject
)
145 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject
, IOleInPlaceObject
)
146 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject
, IOleInPlaceActiveObject
)
147 WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView
, IOleDocumentView
)
148 WX_DECLARE_AUTOOLE(wxAutoIViewObject
, IViewObject
)
149 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceSite
, IOleInPlaceSite
)
150 WX_DECLARE_AUTOOLE(wxAutoIOleDocument
, IOleDocument
)
151 WX_DECLARE_AUTOOLE(wxAutoIPersistStreamInit
, IPersistStreamInit
)
152 WX_DECLARE_AUTOOLE(wxAutoIAdviseSink
, IAdviseSink
)
154 class wxActiveXContainer
: public wxWindow
157 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);
158 virtual ~wxActiveXContainer();
160 void OnSize(wxSizeEvent
&);
161 void OnPaint(wxPaintEvent
&);
162 void OnSetFocus(wxFocusEvent
&);
163 void OnKillFocus(wxFocusEvent
&);
166 friend class FrameSite
;
168 wxAutoIDispatch m_Dispatch
;
169 wxAutoIOleClientSite m_clientSite
;
170 wxAutoIUnknown m_ActiveX
;
171 wxAutoIOleObject m_oleObject
;
172 wxAutoIOleInPlaceObject m_oleInPlaceObject
;
173 wxAutoIOleInPlaceActiveObject m_oleInPlaceActiveObject
;
174 wxAutoIOleDocumentView m_docView
;
175 wxAutoIViewObject m_viewObject
;
176 HWND m_oleObjectHWND
;
177 bool m_bAmbientUserMode
;
178 DWORD m_docAdviseCookie
;
179 wxWindow
* m_realparent
;
181 void CreateActiveX(REFIID
, IUnknown
*);
184 #endif // _WX_MSW_OLE_ACTIVEXCONTAINER_H_