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"
46 //---------------------------------------------------------------------------
48 //---------------------------------------------------------------------------
52 #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
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
63 #ifndef DISPID_READYSTATE
64 #define DISPID_READYSTATE -525
65 #define DISPID_READYSTATECHANGE -609
66 #define DISPID_AMBIENT_TRANSFERPRIORITY -728
69 #define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED -5501
70 #define DISPID_AMBIENT_SILENT -5502
72 #ifndef DISPID_AMBIENT_CODEPAGE
73 # define DISPID_AMBIENT_CODEPAGE -725
74 # define DISPID_AMBIENT_CHARSET -727
78 //---------------------------------------------------------------------------
82 //---------------------------------------------------------------------------
84 #define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \
85 class wxAutoOleInterface \
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)\
101 wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\
104 ti.m_interface->AddRef();\
106 m_interface = ti.m_interface;\
110 wxAutoOleInterface& operator = (I *&ti)\
117 ~wxAutoOleInterface() { Free(); }\
122 m_interface->Release();\
126 HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\
129 wxASSERT(pUnk != NULL);\
130 return pUnk->QueryInterface(riid, (void **) &m_interface);\
133 HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\
136 return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\
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;}\
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
)
158 class wxActiveXContainer
: public wxWindow
161 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);
162 virtual ~wxActiveXContainer();
164 void OnSize(wxSizeEvent
&);
165 void OnPaint(wxPaintEvent
&);
166 void OnSetFocus(wxFocusEvent
&);
167 void OnKillFocus(wxFocusEvent
&);
170 friend class FrameSite
;
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
;
185 void CreateActiveX(REFIID
, IUnknown
*);
188 #endif // _WX_MSW_OLE_ACTIVEXCONTAINER_H_