X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0ed94e8347ab38ea5103d39f5ec28df324598e97..11e3c6ef36393fb5863ea2f9601d8facd73acb12:/include/wx/msw/ole/activex.h?ds=sidebyside diff --git a/include/wx/msw/ole/activex.h b/include/wx/msw/ole/activex.h index f2668e6be9..b350f87320 100644 --- a/include/wx/msw/ole/activex.h +++ b/include/wx/msw/ole/activex.h @@ -16,32 +16,18 @@ #ifndef _WX_MSW_OLE_ACTIVEXCONTAINER_H_ #define _WX_MSW_OLE_ACTIVEXCONTAINER_H_ -//--------------------------------------------------------------------------- -// COM includes -//--------------------------------------------------------------------------- -#include "wx/msw/ole/oleutils.h" //wxBasicString, IID etc. -#include "wx/msw/ole/uuid.h" //IID etc.. +#if wxUSE_ACTIVEX //--------------------------------------------------------------------------- -// COM compatability definitions +// wx includes //--------------------------------------------------------------------------- -#ifndef STDMETHODCALLTYPE -#define STDMETHODCALLTYPE __stdcall -#endif -#ifndef STDMETHOD -#define STDMETHOD(funcname) virtual HRESULT STDMETHODCALLTYPE funcname -#endif -#ifndef PURE -#define PURE = 0 -#endif -#ifndef __RPC_FAR -#define __RPC_FAR FAR -#endif -//--------------------------------------------------------------------------- -// WX includes -//--------------------------------------------------------------------------- +#include "wx/msw/ole/oleutils.h" // wxBasicString &c +#include "wx/msw/ole/uuid.h" #include "wx/window.h" +#include "wx/variant.h" + +class FrameSite; //--------------------------------------------------------------------------- // MSW COM includes @@ -55,23 +41,27 @@ #include +#ifndef STDMETHOD + #define STDMETHOD(funcname) virtual HRESULT wxSTDCALL funcname +#endif + // // These defines are from another ole header - but its not in the // latest sdk. Also the ifndef DISPID_READYSTATE is here because at // least on my machine with the latest sdk olectl.h defines these 3 // #ifndef DISPID_READYSTATE - #define DISPID_READYSTATE -525 - #define DISPID_READYSTATECHANGE -609 - #define DISPID_AMBIENT_TRANSFERPRIORITY -728 + #define DISPID_READYSTATE (-525) + #define DISPID_READYSTATECHANGE (-609) + #define DISPID_AMBIENT_TRANSFERPRIORITY (-728) #endif -#define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED -5501 -#define DISPID_AMBIENT_SILENT -5502 +#define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED (-5501) +#define DISPID_AMBIENT_SILENT (-5502) #ifndef DISPID_AMBIENT_CODEPAGE -# define DISPID_AMBIENT_CODEPAGE -725 -# define DISPID_AMBIENT_CHARSET -727 + #define DISPID_AMBIENT_CODEPAGE (-725) + #define DISPID_AMBIENT_CHARSET (-727) #endif @@ -81,81 +71,94 @@ // //--------------------------------------------------------------------------- -#define WX_DECLARE_AUTOOLE(wxAutoOleInterface, I) \ -class wxAutoOleInterface \ -{ \ - protected: \ - I *m_interface; \ -\ - public: \ - explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) {} \ - wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) \ - { QueryInterface(riid, pUnk); } \ - wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) \ - { QueryInterface(riid, pDispatch); } \ - wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL)\ - { CreateInstance(clsid, riid); }\ - wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL)\ - { operator = (ti); }\ -\ - wxAutoOleInterface& operator = (const wxAutoOleInterface& ti)\ - {\ - if (ti.m_interface)\ - ti.m_interface->AddRef();\ - Free();\ - m_interface = ti.m_interface;\ - return *this;\ - }\ -\ - wxAutoOleInterface& operator = (I *&ti)\ - {\ - Free();\ - m_interface = ti;\ - return *this;\ - }\ -\ - ~wxAutoOleInterface() { Free(); }\ -\ - inline void Free()\ - {\ - if (m_interface)\ - m_interface->Release();\ - m_interface = NULL;\ - }\ -\ - HRESULT QueryInterface(REFIID riid, IUnknown *pUnk)\ - {\ - Free();\ - wxASSERT(pUnk != NULL);\ - return pUnk->QueryInterface(riid, (void **) &m_interface);\ - }\ -\ - HRESULT CreateInstance(REFCLSID clsid, REFIID riid)\ - {\ - Free();\ - return CoCreateInstance(clsid, NULL, CLSCTX_ALL, riid, (void **) &m_interface);\ - }\ -\ - inline operator I *() const {return m_interface;}\ - inline I* operator ->() {return m_interface;}\ - inline I** GetRef() {return &m_interface;}\ - inline bool Ok() const {return m_interface != NULL;}\ +template +class wxAutoOleInterface +{ +public: + typedef I Interface; + + explicit wxAutoOleInterface(I *pInterface = NULL) : m_interface(pInterface) + {} + wxAutoOleInterface(REFIID riid, IUnknown *pUnk) : m_interface(NULL) + { QueryInterface(riid, pUnk); } + wxAutoOleInterface(REFIID riid, IDispatch *pDispatch) : m_interface(NULL) + { QueryInterface(riid, pDispatch); } + wxAutoOleInterface(REFCLSID clsid, REFIID riid) : m_interface(NULL) + { CreateInstance(clsid, riid); } + wxAutoOleInterface(const wxAutoOleInterface& ti) : m_interface(NULL) + { operator=(ti); } + + wxAutoOleInterface& operator=(const wxAutoOleInterface& ti) + { + if ( ti.m_interface ) + ti.m_interface->AddRef(); + Free(); + m_interface = ti.m_interface; + return *this; + } + + wxAutoOleInterface& operator=(I*& ti) + { + Free(); + m_interface = ti; + return *this; + } + + ~wxAutoOleInterface() { Free(); } + + void Free() + { + if ( m_interface ) + m_interface->Release(); + m_interface = NULL; + } + + HRESULT QueryInterface(REFIID riid, IUnknown *pUnk) + { + Free(); + wxASSERT(pUnk != NULL); + return pUnk->QueryInterface(riid, (void **)&m_interface); + } + + HRESULT CreateInstance(REFCLSID clsid, REFIID riid) + { + Free(); + return CoCreateInstance + ( + clsid, + NULL, + CLSCTX_ALL, + riid, + (void **)&m_interface + ); + } + + operator I*() const {return m_interface; } + I* operator->() {return m_interface; } + I** GetRef() {return &m_interface; } + bool Ok() const { return IsOk(); } + bool IsOk() const { return m_interface != NULL; } + +protected: + I *m_interface; }; -WX_DECLARE_AUTOOLE(wxAutoIDispatch, IDispatch) -WX_DECLARE_AUTOOLE(wxAutoIOleClientSite, IOleClientSite) -WX_DECLARE_AUTOOLE(wxAutoIUnknown, IUnknown) -WX_DECLARE_AUTOOLE(wxAutoIOleObject, IOleObject) -WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceObject, IOleInPlaceObject) -WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceActiveObject, IOleInPlaceActiveObject) -WX_DECLARE_AUTOOLE(wxAutoIOleDocumentView, IOleDocumentView) -WX_DECLARE_AUTOOLE(wxAutoIViewObject, IViewObject) -WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceSite, IOleInPlaceSite) -WX_DECLARE_AUTOOLE(wxAutoIOleDocument, IOleDocument) -WX_DECLARE_AUTOOLE(wxAutoIPersistStreamInit, IPersistStreamInit) -WX_DECLARE_AUTOOLE(wxAutoIAdviseSink, IAdviseSink) - -class wxActiveXContainer : public wxWindow +#if WXWIN_COMPATIBILITY_2_8 +// this macro is kept for compatibility with older wx versions +#define WX_DECLARE_AUTOOLE(wxAutoOleInterfaceType, I) \ + typedef wxAutoOleInterface wxAutoOleInterfaceType; +#endif // WXWIN_COMPATIBILITY_2_8 + +typedef wxAutoOleInterface wxAutoIDispatch; +typedef wxAutoOleInterface wxAutoIOleClientSite; +typedef wxAutoOleInterface wxAutoIUnknown; +typedef wxAutoOleInterface wxAutoIOleObject; +typedef wxAutoOleInterface wxAutoIOleInPlaceObject; +typedef wxAutoOleInterface wxAutoIOleInPlaceActiveObject; +typedef wxAutoOleInterface wxAutoIOleDocumentView; +typedef wxAutoOleInterface wxAutoIViewObject; + +class WXDLLIMPEXP_CORE wxActiveXContainer : public wxWindow { public: wxActiveXContainer(wxWindow * parent, REFIID iid, IUnknown* pUnk); @@ -165,10 +168,14 @@ public: void OnPaint(wxPaintEvent&); void OnSetFocus(wxFocusEvent&); void OnKillFocus(wxFocusEvent&); + virtual bool MSWTranslateMessage(WXMSG* pMsg); + virtual bool QueryClientSiteInterface(REFIID iid, void **_interface, const char *&desc); protected: friend class FrameSite; + friend class wxActiveXEvents; + FrameSite *m_frameSite; wxAutoIDispatch m_Dispatch; wxAutoIOleClientSite m_clientSite; wxAutoIUnknown m_ActiveX; @@ -185,4 +192,73 @@ protected: void CreateActiveX(REFIID, IUnknown*); }; +///\brief Store native event parameters. +///\detail Store OLE 'Invoke' parameters for event handlers that need to access them. +/// These are the exact values for the event as they are passed to the wxActiveXContainer. +struct wxActiveXEventNativeMSW +{ + DISPID dispIdMember; + REFIID riid; + LCID lcid; + WORD wFlags; + DISPPARAMS *pDispParams; + VARIANT *pVarResult; + EXCEPINFO *pExcepInfo; + unsigned int *puArgErr; + + wxActiveXEventNativeMSW + (DISPID a_dispIdMember, REFIID a_riid, LCID a_lcid, WORD a_wFlags, DISPPARAMS *a_pDispParams, + VARIANT *a_pVarResult, EXCEPINFO *a_pExcepInfo, unsigned int *a_puArgErr) + :dispIdMember(a_dispIdMember), riid(a_riid), lcid(a_lcid), wFlags(a_wFlags), pDispParams(a_pDispParams), + pVarResult(a_pVarResult), pExcepInfo(a_pExcepInfo), puArgErr(a_puArgErr) + { } +}; + +// Events +class WXDLLIMPEXP_CORE wxActiveXEvent : public wxCommandEvent +{ +private: + friend class wxActiveXEvents; + wxVariant m_params; + DISPID m_dispid; + +public: + virtual wxEvent *Clone() const + { return new wxActiveXEvent(*this); } + + size_t ParamCount() const; + + wxString ParamType(size_t idx) const + { + wxASSERT(idx < ParamCount()); + return m_params[idx].GetType(); + } + + wxString ParamName(size_t idx) const + { + wxASSERT(idx < ParamCount()); + return m_params[idx].GetName(); + } + + wxVariant& operator[] (size_t idx); + + DISPID GetDispatchId() const + { return m_dispid; } + + wxActiveXEventNativeMSW *GetNativeParameters() const + { return (wxActiveXEventNativeMSW*)GetClientData(); } +}; + +// #define wxACTIVEX_ID 14001 +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_CORE, wxEVT_ACTIVEX, wxActiveXEvent ); + +typedef void (wxEvtHandler::*wxActiveXEventFunction)(wxActiveXEvent&); + +#define wxActiveXEventHandler(func) \ + wxEVENT_HANDLER_CAST( wxActiveXEventFunction, func ) + +#define EVT_ACTIVEX(id, fn) wxDECLARE_EVENT_TABLE_ENTRY(wxEVT_ACTIVEX, id, -1, wxActiveXEventHandler( fn ), NULL ), + +#endif // wxUSE_ACTIVEX + #endif // _WX_MSW_OLE_ACTIVEXCONTAINER_H_