2005-09-11 07:04:00 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2006-03-12 09:49:25 -05:00
|
|
|
// Name: wx/msw/ole/activex.h
|
2005-09-11 07:04:00 -04:00
|
|
|
// Purpose: wxActiveXContainer class
|
|
|
|
// Author: Ryan Norton <wxprojects@comcast.net>
|
|
|
|
// Modified by:
|
|
|
|
// Created: 8/18/05
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Ryan Norton
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// Definitions
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
#ifndef _WX_MSW_OLE_ACTIVEXCONTAINER_H_
|
|
|
|
#define _WX_MSW_OLE_ACTIVEXCONTAINER_H_
|
|
|
|
|
2006-10-02 18:37:07 -04:00
|
|
|
#if wxUSE_ACTIVEX
|
2005-09-11 07:04:00 -04:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
2006-10-02 18:37:07 -04:00
|
|
|
// wx includes
|
2005-09-11 07:04:00 -04:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2006-10-02 18:37:07 -04:00
|
|
|
#include "wx/msw/ole/oleutils.h" // wxBasicString &c
|
|
|
|
#include "wx/msw/ole/uuid.h"
|
2005-09-11 07:04:00 -04:00
|
|
|
#include "wx/window.h"
|
2006-02-10 14:37:40 -05:00
|
|
|
#include "wx/variant.h"
|
2005-09-11 07:04:00 -04:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// MSW COM includes
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#include <oleidl.h>
|
|
|
|
#include <olectl.h>
|
2005-10-27 17:22:48 -04:00
|
|
|
|
|
|
|
#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__)
|
2005-09-11 07:04:00 -04:00
|
|
|
#include <exdisp.h>
|
2005-10-27 17:22:48 -04:00
|
|
|
#endif
|
|
|
|
|
2005-09-11 07:04:00 -04:00
|
|
|
#include <docobj.h>
|
|
|
|
|
2006-10-02 18:37:07 -04:00
|
|
|
#ifndef STDMETHOD
|
|
|
|
#define STDMETHOD(funcname) virtual HRESULT wxSTDCALL funcname
|
|
|
|
#endif
|
|
|
|
|
2005-09-11 07:04:00 -04:00
|
|
|
//
|
|
|
|
// 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
|
2006-10-02 18:37:07 -04:00
|
|
|
#define DISPID_READYSTATE (-525)
|
|
|
|
#define DISPID_READYSTATECHANGE (-609)
|
|
|
|
#define DISPID_AMBIENT_TRANSFERPRIORITY (-728)
|
2005-09-11 07:04:00 -04:00
|
|
|
#endif
|
|
|
|
|
2006-10-02 18:37:07 -04:00
|
|
|
#define DISPID_AMBIENT_OFFLINEIFNOTCONNECTED (-5501)
|
|
|
|
#define DISPID_AMBIENT_SILENT (-5502)
|
2005-09-11 07:04:00 -04:00
|
|
|
|
|
|
|
#ifndef DISPID_AMBIENT_CODEPAGE
|
2006-10-02 18:37:07 -04:00
|
|
|
#define DISPID_AMBIENT_CODEPAGE (-725)
|
|
|
|
#define DISPID_AMBIENT_CHARSET (-727)
|
2005-09-11 07:04:00 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// wxActiveXContainer
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#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;}\
|
2006-10-09 05:32:08 -04:00
|
|
|
inline bool Ok() const { return IsOk(); }\
|
2006-10-08 17:56:55 -04:00
|
|
|
inline bool IsOk() const {return m_interface != NULL;}\
|
2005-09-11 07:04:00 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
class wxActiveXContainer : public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxActiveXContainer(wxWindow * parent, REFIID iid, IUnknown* pUnk);
|
|
|
|
virtual ~wxActiveXContainer();
|
|
|
|
|
|
|
|
void OnSize(wxSizeEvent&);
|
|
|
|
void OnPaint(wxPaintEvent&);
|
|
|
|
void OnSetFocus(wxFocusEvent&);
|
|
|
|
void OnKillFocus(wxFocusEvent&);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
friend class FrameSite;
|
2006-02-10 14:37:40 -05:00
|
|
|
friend class wxActiveXEvents;
|
2005-09-11 07:04:00 -04:00
|
|
|
|
|
|
|
wxAutoIDispatch m_Dispatch;
|
|
|
|
wxAutoIOleClientSite m_clientSite;
|
|
|
|
wxAutoIUnknown m_ActiveX;
|
|
|
|
wxAutoIOleObject m_oleObject;
|
|
|
|
wxAutoIOleInPlaceObject m_oleInPlaceObject;
|
|
|
|
wxAutoIOleInPlaceActiveObject m_oleInPlaceActiveObject;
|
|
|
|
wxAutoIOleDocumentView m_docView;
|
|
|
|
wxAutoIViewObject m_viewObject;
|
|
|
|
HWND m_oleObjectHWND;
|
|
|
|
bool m_bAmbientUserMode;
|
|
|
|
DWORD m_docAdviseCookie;
|
|
|
|
wxWindow* m_realparent;
|
|
|
|
|
|
|
|
void CreateActiveX(REFIID, IUnknown*);
|
|
|
|
};
|
|
|
|
|
2006-02-10 14:37:40 -05:00
|
|
|
|
|
|
|
// Events
|
|
|
|
class wxActiveXEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class wxActiveXEvents;
|
|
|
|
wxVariant m_params;
|
|
|
|
DISPID m_dispid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual wxEvent *Clone() const
|
|
|
|
{ return new wxActiveXEvent(*this); }
|
|
|
|
|
2006-03-12 09:49:25 -05:00
|
|
|
size_t ParamCount() const
|
2006-02-10 14:37:40 -05:00
|
|
|
{ return m_params.GetCount(); }
|
|
|
|
|
2006-03-12 09:49:25 -05:00
|
|
|
wxString ParamType(size_t idx) const
|
2006-02-10 14:37:40 -05:00
|
|
|
{
|
2006-03-12 09:49:25 -05:00
|
|
|
wxASSERT(idx < m_params.GetCount());
|
2006-02-10 14:37:40 -05:00
|
|
|
return m_params[idx].GetType();
|
|
|
|
}
|
|
|
|
|
2006-03-12 09:49:25 -05:00
|
|
|
wxString ParamName(size_t idx) const
|
2006-02-10 14:37:40 -05:00
|
|
|
{
|
2006-03-12 09:49:25 -05:00
|
|
|
wxASSERT(idx < m_params.GetCount());
|
2006-02-10 14:37:40 -05:00
|
|
|
return m_params[idx].GetName();
|
|
|
|
}
|
|
|
|
|
2006-03-12 09:49:25 -05:00
|
|
|
wxVariant& operator[] (size_t idx)
|
2006-02-10 14:37:40 -05:00
|
|
|
{
|
2006-03-12 09:49:25 -05:00
|
|
|
wxASSERT(idx < ParamCount());
|
2006-02-10 14:37:40 -05:00
|
|
|
return m_params[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
DISPID GetDispatchId() const
|
|
|
|
{ return m_dispid; }
|
|
|
|
};
|
|
|
|
|
|
|
|
#define wxACTIVEX_ID 14001
|
|
|
|
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_ACTIVEX, wxACTIVEX_ID)
|
|
|
|
typedef void (wxEvtHandler::*wxActiveXEventFunction)(wxActiveXEvent&);
|
|
|
|
#define EVT_ACTIVEX(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_ACTIVEX, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxActiveXEventFunction) & fn, (wxObject *) NULL ),
|
|
|
|
#define wxActiveXEventHandler(func) \
|
|
|
|
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxActiveXEventFunction, &func)
|
|
|
|
|
2006-10-02 18:37:07 -04:00
|
|
|
#endif // wxUSE_ACTIVEX
|
|
|
|
|
2005-09-11 07:04:00 -04:00
|
|
|
#endif // _WX_MSW_OLE_ACTIVEXCONTAINER_H_
|