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_
21 //---------------------------------------------------------------------------
23 //---------------------------------------------------------------------------
25 #include "wx/msw/ole/oleutils.h" // wxBasicString &c
26 #include "wx/msw/ole/uuid.h"
27 #include "wx/window.h"
28 #include "wx/variant.h"
32 //---------------------------------------------------------------------------
34 //---------------------------------------------------------------------------
38 #if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
45 #define STDMETHOD(funcname) virtual HRESULT wxSTDCALL funcname
49 // These defines are from another ole header - but its not in the
50 // latest sdk. Also the ifndef DISPID_READYSTATE is here because at
51 // least on my machine with the latest sdk olectl.h defines these 3
53 #ifndef DISPID_READYSTATE
54 #define DISPID_READYSTATE (-525)
55 #define DISPID_READYSTATECHANGE (-609)
56 #define DISPID_AMBIENT_TRANSFERPRIORITY (-728)
59 #define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED (-5501)
60 #define DISPID_AMBIENT_SILENT (-5502)
62 #ifndef DISPID_AMBIENT_CODEPAGE
63 #define DISPID_AMBIENT_CODEPAGE (-725)
64 #define DISPID_AMBIENT_CHARSET (-727)
68 //---------------------------------------------------------------------------
72 //---------------------------------------------------------------------------
74 #define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \
75 class wxAutoOleInterface \
81 explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \
82 wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \
83 { QueryInterface(riid, pUnk); } \
84 wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \
85 { QueryInterface(riid, pDispatch); } \
86 wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\
87 { CreateInstance(clsid, riid); }\
88 wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\
91 wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\
94 ti.m_interface->AddRef();\
96 m_interface = ti.m_interface;\
100 wxAutoOleInterface& operator = (I *&ti)\
107 ~wxAutoOleInterface() { Free(); }\
112 m_interface->Release();\
116 HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\
119 wxASSERT(pUnk != NULL);\
120 return pUnk->QueryInterface(riid, (void **) &m_interface);\
123 HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\
126 return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\
129 inline operator I *() const {return m_interface;}\
130 inline I* operator ->() {return m_interface;}\
131 inline I** GetRef() {return &m_interface;}\
132 inline bool Ok() const { return IsOk(); }\
133 inline bool IsOk() const {return m_interface != NULL;}\
136 WX_DECLARE_AUTOOLE(wxAutoIDispatch
, IDispatch
)
137 WX_DECLARE_AUTOOLE(wxAutoIOleClientSite
, IOleClientSite
)
138 WX_DECLARE_AUTOOLE(wxAutoIUnknown
, IUnknown
)
139 WX_DECLARE_AUTOOLE(wxAutoIOleObject
, IOleObject
)
140 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject
, IOleInPlaceObject
)
141 WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject
, IOleInPlaceActiveObject
)
142 WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView
, IOleDocumentView
)
143 WX_DECLARE_AUTOOLE(wxAutoIViewObject
, IViewObject
)
145 class WXDLLIMPEXP_CORE wxActiveXContainer
: public wxWindow
148 wxActiveXContainer(wxWindow
* parent
, REFIID iid
, IUnknown
* pUnk
);
149 virtual ~wxActiveXContainer();
151 void OnSize(wxSizeEvent
&);
152 void OnPaint(wxPaintEvent
&);
153 void OnSetFocus(wxFocusEvent
&);
154 void OnKillFocus(wxFocusEvent
&);
157 friend class FrameSite
;
158 friend class wxActiveXEvents
;
160 FrameSite
*m_frameSite
;
161 wxAutoIDispatch m_Dispatch
;
162 wxAutoIOleClientSite m_clientSite
;
163 wxAutoIUnknown m_ActiveX
;
164 wxAutoIOleObject m_oleObject
;
165 wxAutoIOleInPlaceObject m_oleInPlaceObject
;
166 wxAutoIOleInPlaceActiveObject m_oleInPlaceActiveObject
;
167 wxAutoIOleDocumentView m_docView
;
168 wxAutoIViewObject m_viewObject
;
169 HWND m_oleObjectHWND
;
170 bool m_bAmbientUserMode
;
171 DWORD m_docAdviseCookie
;
172 wxWindow
* m_realparent
;
174 void CreateActiveX(REFIID
, IUnknown
*);
179 class WXDLLIMPEXP_CORE wxActiveXEvent
: public wxCommandEvent
182 friend class wxActiveXEvents
;
187 virtual wxEvent
*Clone() const
188 { return new wxActiveXEvent(*this); }
190 size_t ParamCount() const
191 { return m_params
.GetCount(); }
193 wxString
ParamType(size_t idx
) const
195 wxASSERT(idx
< m_params
.GetCount());
196 return m_params
[idx
].GetType();
199 wxString
ParamName(size_t idx
) const
201 wxASSERT(idx
< m_params
.GetCount());
202 return m_params
[idx
].GetName();
205 wxVariant
& operator[] (size_t idx
)
207 wxASSERT(idx
< ParamCount());
208 return m_params
[idx
];
211 DISPID
GetDispatchId() const
215 // #define wxACTIVEX_ID 14001
216 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE
, wxEVT_ACTIVEX
, wxActiveXEvent
)
218 typedef void (wxEvtHandler::*wxActiveXEventFunction
)(wxActiveXEvent
&);
220 #define wxActiveXEventHandler(func) \
221 wxEVENT_HANDLER_CAST( wxActiveXEventFunction, func )
223 #define EVT_ACTIVEX(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_ACTIVEX, id, -1, wxActiveXEventHandler( fn ), NULL ),
225 #endif // wxUSE_ACTIVEX
227 #endif // _WX_MSW_OLE_ACTIVEXCONTAINER_H_