2002-07-03 22:05:30 +00:00
|
|
|
#include "wxActiveX.h"
|
|
|
|
#include <wx/strconv.h>
|
2002-07-11 17:43:34 +00:00
|
|
|
#include <wx/event.h>
|
2002-07-03 22:05:30 +00:00
|
|
|
#include <oleidl.h>
|
|
|
|
#include <winerror.h>
|
|
|
|
#include <idispids.h>
|
|
|
|
#include <exdispid.h>
|
|
|
|
#include <olectl.h>
|
|
|
|
#include <Mshtml.h>
|
|
|
|
#include <sstream>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
// Depending on compilation mode, the wx headers may have undef'd
|
|
|
|
// this, but in this case we need it so the virtual method in
|
|
|
|
// FrameSite will match what is in oleidl.h.
|
|
|
|
#ifndef GetObject
|
|
|
|
#ifdef _UNICODE
|
|
|
|
#define GetObject GetObjectW
|
|
|
|
#else
|
|
|
|
#define GetObject GetObjectA
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
BEGIN_EVENT_TABLE(wxActiveX, wxWindow)
|
2002-08-08 18:29:59 +00:00
|
|
|
EVT_SIZE(wxActiveX::OnSize)
|
|
|
|
EVT_PAINT(wxActiveX::OnPaint)
|
|
|
|
EVT_MOUSE_EVENTS(wxActiveX::OnMouse)
|
|
|
|
EVT_SET_FOCUS(wxActiveX::OnSetFocus)
|
|
|
|
EVT_KILL_FOCUS(wxActiveX::OnKillFocus)
|
2002-07-03 22:05:30 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
class wxActiveX;
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
class FrameSite :
|
2002-07-03 22:05:30 +00:00
|
|
|
public IOleClientSite,
|
|
|
|
public IOleInPlaceSiteEx,
|
|
|
|
public IOleInPlaceFrame,
|
|
|
|
public IOleItemContainer,
|
|
|
|
public IDispatch,
|
|
|
|
public IOleCommandTarget,
|
|
|
|
public IOleDocumentSite,
|
|
|
|
public IAdviseSink,
|
|
|
|
public IOleControlSite
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
DECLARE_OLE_UNKNOWN(FrameSite);
|
|
|
|
|
|
|
|
public:
|
|
|
|
FrameSite(wxActiveX * win);
|
2002-08-08 18:29:59 +00:00
|
|
|
virtual ~FrameSite();
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
//IOleWindow
|
|
|
|
STDMETHODIMP GetWindow(HWND*);
|
|
|
|
STDMETHODIMP ContextSensitiveHelp(BOOL);
|
|
|
|
|
|
|
|
//IOleInPlaceUIWindow
|
|
|
|
STDMETHODIMP GetBorder(LPRECT);
|
|
|
|
STDMETHODIMP RequestBorderSpace(LPCBORDERWIDTHS);
|
|
|
|
STDMETHODIMP SetBorderSpace(LPCBORDERWIDTHS);
|
|
|
|
STDMETHODIMP SetActiveObject(IOleInPlaceActiveObject*, LPCOLESTR);
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
//IOleInPlaceFrame
|
|
|
|
STDMETHODIMP InsertMenus(HMENU, LPOLEMENUGROUPWIDTHS);
|
|
|
|
STDMETHODIMP SetMenu(HMENU, HOLEMENU, HWND);
|
|
|
|
STDMETHODIMP RemoveMenus(HMENU);
|
|
|
|
STDMETHODIMP SetStatusText(LPCOLESTR);
|
|
|
|
STDMETHODIMP EnableModeless(BOOL);
|
|
|
|
STDMETHODIMP TranslateAccelerator(LPMSG, WORD);
|
|
|
|
|
|
|
|
//IOleInPlaceSite
|
|
|
|
STDMETHODIMP CanInPlaceActivate();
|
|
|
|
STDMETHODIMP OnInPlaceActivate();
|
|
|
|
STDMETHODIMP OnUIActivate();
|
2003-03-25 06:35:27 +00:00
|
|
|
STDMETHODIMP GetWindowContext(IOleInPlaceFrame**, IOleInPlaceUIWindow**,
|
2002-07-03 22:05:30 +00:00
|
|
|
LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO);
|
|
|
|
STDMETHODIMP Scroll(SIZE);
|
|
|
|
STDMETHODIMP OnUIDeactivate(BOOL);
|
|
|
|
STDMETHODIMP OnInPlaceDeactivate();
|
|
|
|
STDMETHODIMP DiscardUndoState();
|
|
|
|
STDMETHODIMP DeactivateAndUndo();
|
|
|
|
STDMETHODIMP OnPosRectChange(LPCRECT);
|
|
|
|
|
|
|
|
//IOleInPlaceSiteEx
|
|
|
|
STDMETHODIMP OnInPlaceActivateEx(BOOL*, DWORD);
|
|
|
|
STDMETHODIMP OnInPlaceDeactivateEx(BOOL);
|
|
|
|
STDMETHODIMP RequestUIActivate();
|
|
|
|
|
|
|
|
//IOleClientSite
|
|
|
|
STDMETHODIMP SaveObject();
|
|
|
|
STDMETHODIMP GetMoniker(DWORD, DWORD, IMoniker**);
|
|
|
|
STDMETHODIMP GetContainer(LPOLECONTAINER FAR*);
|
|
|
|
STDMETHODIMP ShowObject();
|
|
|
|
STDMETHODIMP OnShowWindow(BOOL);
|
|
|
|
STDMETHODIMP RequestNewObjectLayout();
|
|
|
|
|
|
|
|
//IOleControlSite
|
|
|
|
STDMETHODIMP OnControlInfoChanged();
|
|
|
|
STDMETHODIMP LockInPlaceActive(BOOL);
|
|
|
|
STDMETHODIMP GetExtendedControl(IDispatch**);
|
|
|
|
STDMETHODIMP TransformCoords(POINTL*, POINTF*, DWORD);
|
|
|
|
STDMETHODIMP TranslateAccelerator(LPMSG, DWORD);
|
|
|
|
STDMETHODIMP OnFocus(BOOL);
|
|
|
|
STDMETHODIMP ShowPropertyFrame();
|
|
|
|
|
|
|
|
//IOleCommandTarget
|
|
|
|
STDMETHODIMP QueryStatus(const GUID*, ULONG, OLECMD[], OLECMDTEXT*);
|
|
|
|
STDMETHODIMP Exec(const GUID*, DWORD, DWORD, VARIANTARG*, VARIANTARG*);
|
|
|
|
|
|
|
|
//IParseDisplayName
|
|
|
|
STDMETHODIMP ParseDisplayName(IBindCtx*, LPOLESTR, ULONG*, IMoniker**);
|
|
|
|
|
|
|
|
//IOleContainer
|
|
|
|
STDMETHODIMP EnumObjects(DWORD, IEnumUnknown**);
|
|
|
|
STDMETHODIMP LockContainer(BOOL);
|
|
|
|
|
|
|
|
//IOleItemContainer
|
|
|
|
STDMETHODIMP GetObject(LPOLESTR, DWORD, IBindCtx*, REFIID, void**);
|
|
|
|
STDMETHODIMP GetObjectStorage(LPOLESTR, IBindCtx*, REFIID, void**);
|
|
|
|
STDMETHODIMP IsRunning(LPOLESTR);
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
//IDispatch
|
|
|
|
STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR**, unsigned int, LCID, DISPID*);
|
|
|
|
STDMETHODIMP GetTypeInfo(unsigned int, LCID, ITypeInfo**);
|
|
|
|
STDMETHODIMP GetTypeInfoCount(unsigned int*);
|
|
|
|
STDMETHODIMP Invoke(DISPID, REFIID, LCID, WORD, DISPPARAMS*, VARIANT*, EXCEPINFO*, UINT*);
|
|
|
|
|
|
|
|
//IAdviseSink
|
|
|
|
void STDMETHODCALLTYPE OnDataChange(FORMATETC*, STGMEDIUM*);
|
|
|
|
void STDMETHODCALLTYPE OnViewChange(DWORD, LONG);
|
|
|
|
void STDMETHODCALLTYPE OnRename(IMoniker*);
|
|
|
|
void STDMETHODCALLTYPE OnSave();
|
|
|
|
void STDMETHODCALLTYPE OnClose();
|
|
|
|
|
|
|
|
// IOleDocumentSite
|
|
|
|
HRESULT STDMETHODCALLTYPE ActivateMe(IOleDocumentView __RPC_FAR *pViewToActivate);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
wxActiveX * m_window;
|
|
|
|
|
|
|
|
HDC m_hDCBuffer;
|
|
|
|
HWND m_hWndParent;
|
|
|
|
|
|
|
|
bool m_bSupportsWindowlessActivation;
|
|
|
|
bool m_bInPlaceLocked;
|
|
|
|
bool m_bInPlaceActive;
|
|
|
|
bool m_bUIActive;
|
|
|
|
bool m_bWindowless;
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
LCID m_nAmbientLocale;
|
|
|
|
COLORREF m_clrAmbientForeColor;
|
|
|
|
COLORREF m_clrAmbientBackColor;
|
|
|
|
bool m_bAmbientShowHatching;
|
|
|
|
bool m_bAmbientShowGrabHandles;
|
|
|
|
bool m_bAmbientAppearance;
|
|
|
|
};
|
|
|
|
|
|
|
|
DEFINE_OLE_TABLE(FrameSite)
|
|
|
|
OLE_INTERFACE(IID_IUnknown, IOleClientSite)
|
|
|
|
|
|
|
|
OLE_IINTERFACE(IOleClientSite)
|
|
|
|
|
|
|
|
OLE_INTERFACE(IID_IOleWindow, IOleInPlaceSite)
|
|
|
|
OLE_IINTERFACE(IOleInPlaceSite)
|
|
|
|
OLE_IINTERFACE(IOleInPlaceSiteEx)
|
|
|
|
|
|
|
|
//OLE_IINTERFACE(IOleWindow)
|
|
|
|
OLE_IINTERFACE(IOleInPlaceUIWindow)
|
|
|
|
OLE_IINTERFACE(IOleInPlaceFrame)
|
|
|
|
|
|
|
|
OLE_IINTERFACE(IParseDisplayName)
|
|
|
|
OLE_IINTERFACE(IOleContainer)
|
|
|
|
OLE_IINTERFACE(IOleItemContainer)
|
|
|
|
|
|
|
|
OLE_IINTERFACE(IDispatch)
|
|
|
|
|
|
|
|
OLE_IINTERFACE(IOleCommandTarget)
|
|
|
|
|
|
|
|
OLE_IINTERFACE(IOleDocumentSite)
|
|
|
|
|
|
|
|
OLE_IINTERFACE(IAdviseSink)
|
|
|
|
|
|
|
|
OLE_IINTERFACE(IOleControlSite)
|
|
|
|
END_OLE_TABLE;
|
|
|
|
|
|
|
|
|
2002-07-06 00:42:51 +00:00
|
|
|
wxActiveX::wxActiveX(wxWindow * parent, REFCLSID clsid, wxWindowID id,
|
2002-07-11 17:43:34 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style,
|
|
|
|
const wxString& name) :
|
|
|
|
wxWindow(parent, id, pos, size, style, name)
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
2002-07-11 17:43:34 +00:00
|
|
|
m_bAmbientUserMode = true;
|
2002-07-03 22:05:30 +00:00
|
|
|
m_docAdviseCookie = 0;
|
2002-07-11 17:43:34 +00:00
|
|
|
CreateActiveX(clsid);
|
2002-07-03 22:05:30 +00:00
|
|
|
}
|
|
|
|
|
2002-07-06 00:42:51 +00:00
|
|
|
wxActiveX::wxActiveX(wxWindow * parent, wxString progId, wxWindowID id,
|
2002-07-11 17:43:34 +00:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style,
|
|
|
|
const wxString& name) :
|
|
|
|
wxWindow(parent, id, pos, size, style, name)
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
2002-07-11 17:43:34 +00:00
|
|
|
m_bAmbientUserMode = true;
|
2002-07-03 22:05:30 +00:00
|
|
|
m_docAdviseCookie = 0;
|
2002-07-20 00:06:59 +00:00
|
|
|
CreateActiveX((LPOLESTR) (const wchar_t *) progId.wc_str(wxConvUTF8));
|
2002-07-03 22:05:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
wxActiveX::~wxActiveX()
|
|
|
|
{
|
|
|
|
// disconnect connection points
|
|
|
|
wxOleConnectionArray::iterator it = m_connections.begin();
|
|
|
|
while (it != m_connections.end())
|
|
|
|
{
|
|
|
|
wxOleConnectionPoint& cp = it->first;
|
|
|
|
cp->Unadvise(it->second);
|
|
|
|
|
|
|
|
it++;
|
|
|
|
};
|
|
|
|
m_connections.clear();
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if (m_oleInPlaceObject.Ok())
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
|
|
|
m_oleInPlaceObject->InPlaceDeactivate();
|
|
|
|
m_oleInPlaceObject->UIDeactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if (m_oleObject.Ok())
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
|
|
|
if (m_docAdviseCookie != 0)
|
|
|
|
m_oleObject->Unadvise(m_docAdviseCookie);
|
|
|
|
|
|
|
|
m_oleObject->DoVerb(OLEIVERB_HIDE, NULL, m_clientSite, 0, (HWND) GetHWND(), NULL);
|
|
|
|
m_oleObject->Close(OLECLOSE_NOSAVE);
|
|
|
|
m_oleObject->SetClientSite(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxActiveX::CreateActiveX(REFCLSID clsid)
|
|
|
|
{
|
|
|
|
SetTransparent();
|
|
|
|
|
|
|
|
HRESULT hret;
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
|
|
// FrameSite
|
|
|
|
FrameSite *frame = new FrameSite(this);
|
|
|
|
// oleClientSite
|
|
|
|
hret = m_clientSite.QueryInterface(IID_IOleClientSite, (IDispatch *) frame);
|
|
|
|
wxASSERT(SUCCEEDED(hret));
|
|
|
|
// adviseSink
|
|
|
|
wxAutoOleInterface<IAdviseSink> adviseSink(IID_IAdviseSink, (IDispatch *) frame);
|
|
|
|
wxASSERT(adviseSink.Ok());
|
|
|
|
|
|
|
|
|
|
|
|
// // Create Object, get IUnknown interface
|
|
|
|
m_ActiveX.CreateInstance(clsid, IID_IUnknown);
|
|
|
|
wxASSERT(m_ActiveX.Ok());
|
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
// Type Info
|
|
|
|
GetTypeInfo();
|
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
// Get IOleObject interface
|
2003-03-25 06:35:27 +00:00
|
|
|
hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX);
|
2002-07-03 22:05:30 +00:00
|
|
|
wxASSERT(SUCCEEDED(hret));
|
2002-07-20 00:06:59 +00:00
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
// get IViewObject Interface
|
2003-03-25 06:35:27 +00:00
|
|
|
hret = m_viewObject.QueryInterface(IID_IViewObject, m_ActiveX);
|
2002-08-08 18:29:59 +00:00
|
|
|
wxASSERT(SUCCEEDED(hret));
|
|
|
|
|
2002-07-20 00:06:59 +00:00
|
|
|
// document advise
|
|
|
|
m_docAdviseCookie = 0;
|
|
|
|
hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie);
|
|
|
|
WXOLE_WARN(hret, "m_oleObject->Advise(adviseSink, &m_docAdviseCookie),\"Advise\")");
|
|
|
|
m_oleObject->SetHostNames(L"wxActiveXContainer", NULL);
|
|
|
|
OleSetContainedObject(m_oleObject, TRUE);
|
|
|
|
OleRun(m_oleObject);
|
|
|
|
|
|
|
|
|
|
|
|
// Get IOleInPlaceObject interface
|
2002-07-03 22:05:30 +00:00
|
|
|
hret = m_oleInPlaceObject.QueryInterface(IID_IOleInPlaceObject, m_ActiveX);
|
|
|
|
wxASSERT(SUCCEEDED(hret));
|
|
|
|
|
|
|
|
// status
|
|
|
|
DWORD dwMiscStatus;
|
|
|
|
m_oleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
|
|
|
|
wxASSERT(SUCCEEDED(hret));
|
|
|
|
|
|
|
|
// set client site first ?
|
|
|
|
if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)
|
|
|
|
m_oleObject->SetClientSite(m_clientSite);
|
|
|
|
|
|
|
|
|
|
|
|
// stream init
|
|
|
|
wxAutoOleInterface<IPersistStreamInit>
|
|
|
|
pPersistStreamInit(IID_IPersistStreamInit, m_oleObject);
|
|
|
|
|
|
|
|
if (pPersistStreamInit.Ok())
|
|
|
|
{
|
|
|
|
hret = pPersistStreamInit->InitNew();
|
|
|
|
WXOLE_WARN(hret, "CreateActiveX::pPersistStreamInit->InitNew()");
|
|
|
|
};
|
|
|
|
|
|
|
|
if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
|
|
|
|
m_oleObject->SetClientSite(m_clientSite);
|
|
|
|
|
|
|
|
|
|
|
|
int w, h;
|
|
|
|
GetClientSize(&w, &h);
|
|
|
|
RECT posRect;
|
|
|
|
posRect.left = 0;
|
|
|
|
posRect.top = 0;
|
|
|
|
posRect.right = w;
|
|
|
|
posRect.bottom = h;
|
|
|
|
|
|
|
|
m_oleObjectHWND = 0;
|
2002-07-20 00:06:59 +00:00
|
|
|
|
|
|
|
if (m_oleInPlaceObject.Ok())
|
|
|
|
{
|
|
|
|
hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
|
|
|
|
WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
|
|
|
|
if (SUCCEEDED(hret))
|
|
|
|
::SetActiveWindow(m_oleObjectHWND);
|
|
|
|
};
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME))
|
|
|
|
{
|
2002-07-20 00:06:59 +00:00
|
|
|
if (w > 0 && h > 0 && m_oleInPlaceObject.Ok())
|
2002-07-11 17:43:34 +00:00
|
|
|
m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, m_clientSite, 0, (HWND)GetHWND(), &posRect);
|
|
|
|
hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0, (HWND)GetHWND(), &posRect);
|
|
|
|
};
|
|
|
|
|
2002-07-20 00:06:59 +00:00
|
|
|
if (! m_oleObjectHWND && m_oleInPlaceObject.Ok())
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
|
|
|
hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
|
|
|
|
WXOLE_WARN(hret, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
|
|
|
|
};
|
|
|
|
|
|
|
|
if (m_oleObjectHWND)
|
|
|
|
{
|
|
|
|
::SetActiveWindow(m_oleObjectHWND);
|
|
|
|
::ShowWindow(m_oleObjectHWND, SW_SHOW);
|
|
|
|
};
|
2002-07-03 22:05:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wxActiveX::CreateActiveX(LPOLESTR progId)
|
|
|
|
{
|
|
|
|
CLSID clsid;
|
|
|
|
if (CLSIDFromProgID(progId, &clsid) != S_OK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CreateActiveX(clsid);
|
|
|
|
};
|
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Case Insensitive Map of Event names to eventTypes
|
|
|
|
// created dynamically at run time in:
|
|
|
|
// EVT_ACTIVEX(eventName, id, fn)
|
|
|
|
// we map the pointer to them so that:
|
|
|
|
// const wxEventType& RegisterActiveXEvent(wxString eventName);
|
|
|
|
// can return a const reference, which is neccessary for event tables
|
|
|
|
// probably should use a wxWindows hash table here, but I'm lazy ...
|
|
|
|
struct less_wxStringI
|
|
|
|
{
|
|
|
|
bool operator()(const wxString& x, const wxString& y) const
|
|
|
|
{
|
|
|
|
return x.CmpNoCase(y) < 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
typedef map<wxString, wxEventType *, less_wxStringI> ActiveXNamedEventMap;
|
|
|
|
static ActiveXNamedEventMap sg_NamedEventMap;
|
2002-07-11 17:43:34 +00:00
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
const wxEventType& RegisterActiveXEvent(const wxChar *eventName)
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
2002-08-08 18:29:59 +00:00
|
|
|
wxString ev = eventName;
|
|
|
|
ActiveXNamedEventMap::iterator it = sg_NamedEventMap.find(ev);
|
|
|
|
if (it == sg_NamedEventMap.end())
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
2002-08-08 18:29:59 +00:00
|
|
|
wxEventType *et = new wxEventType(wxNewEventType());
|
|
|
|
sg_NamedEventMap[ev] = et;
|
|
|
|
|
|
|
|
return *et;
|
2002-07-11 17:43:34 +00:00
|
|
|
};
|
2002-08-08 18:29:59 +00:00
|
|
|
|
|
|
|
return *(it->second);
|
2002-07-11 17:43:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Map of Event DISPID's to eventTypes
|
|
|
|
// created dynamically at run time in:
|
|
|
|
// EVT_ACTIVEX(eventName, id, fn)
|
|
|
|
// we map the pointer to them so that:
|
|
|
|
// const wxEventType& RegisterActiveXEvent(wxString eventName);
|
|
|
|
// can return a const reference, which is neccessary for event tables
|
|
|
|
|
|
|
|
typedef map<DISPID, wxEventType *> ActiveXDISPIDEventMap;
|
|
|
|
static ActiveXDISPIDEventMap sg_dispIdEventMap;
|
|
|
|
|
|
|
|
const wxEventType& RegisterActiveXEvent(DISPID event)
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
2002-08-08 18:29:59 +00:00
|
|
|
ActiveXDISPIDEventMap::iterator it = sg_dispIdEventMap.find(event);
|
|
|
|
if (it == sg_dispIdEventMap.end())
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
|
|
|
wxEventType *et = new wxEventType(wxNewEventType());
|
2002-08-08 18:29:59 +00:00
|
|
|
sg_dispIdEventMap[event] = et;
|
2002-07-11 17:43:34 +00:00
|
|
|
|
|
|
|
return *et;
|
|
|
|
};
|
|
|
|
|
|
|
|
return *(it->second);
|
|
|
|
};
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
// one off class for automatic freeing of activeX eventtypes
|
|
|
|
class ActiveXEventMapFlusher
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~ActiveXEventMapFlusher()
|
|
|
|
{
|
|
|
|
// Named events
|
|
|
|
ActiveXNamedEventMap::iterator it = sg_NamedEventMap.end();
|
|
|
|
while (it != sg_NamedEventMap.end())
|
|
|
|
{
|
|
|
|
delete it->second;
|
|
|
|
it++;
|
|
|
|
};
|
|
|
|
|
|
|
|
// DISPID events
|
|
|
|
ActiveXDISPIDEventMap::iterator dit = sg_dispIdEventMap.end();
|
|
|
|
while (dit != sg_dispIdEventMap.end())
|
|
|
|
{
|
|
|
|
delete dit->second;
|
|
|
|
dit++;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
static ActiveXEventMapFlusher s_dummyActiveXEventMapFlusher;
|
|
|
|
|
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
bool MSWVariantToVariant(VARIANTARG& va, wxVariant& vx)
|
|
|
|
{
|
|
|
|
switch(va.vt)
|
|
|
|
{
|
|
|
|
case VT_VARIANT | VT_BYREF:
|
|
|
|
return MSWVariantToVariant(*va.pvarVal, vx);
|
|
|
|
|
|
|
|
case VT_I2:
|
|
|
|
case VT_I4:
|
|
|
|
vx = (long) va.iVal;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_I2 | VT_BYREF:
|
|
|
|
case VT_I4 | VT_BYREF:
|
|
|
|
vx = (long) *va.piVal;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_BSTR:
|
|
|
|
vx = wxString(va.bstrVal);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_BSTR | VT_BYREF:
|
|
|
|
vx = wxString(*va.pbstrVal);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_BOOL:
|
|
|
|
vx = (va.boolVal != FALSE);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_BOOL | VT_BYREF:
|
|
|
|
vx = (*va.pboolVal != FALSE);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
vx.MakeNull();
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
bool VariantToMSWVariant(wxVariant& vx, VARIANTARG& va)
|
|
|
|
{
|
|
|
|
switch(va.vt)
|
|
|
|
{
|
|
|
|
case VT_VARIANT | VT_BYREF:
|
|
|
|
return VariantToMSWVariant(vx, va);
|
|
|
|
|
|
|
|
case VT_I2:
|
|
|
|
case VT_I4:
|
|
|
|
va.iVal = (long) vx;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_I2 | VT_BYREF:
|
|
|
|
case VT_I4 | VT_BYREF:
|
|
|
|
*va.piVal = (long) vx;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_BOOL:
|
|
|
|
va.boolVal = ((bool) vx) ? TRUE : FALSE;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case VT_BOOL | VT_BYREF:
|
|
|
|
*va.pboolVal = ((bool) vx) ? TRUE : FALSE;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
class wxActiveXEvents : public IDispatch
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
DECLARE_OLE_UNKNOWN(wxActiveXEvents);
|
|
|
|
|
|
|
|
|
|
|
|
wxActiveX *m_activeX;
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxActiveXEvents(wxActiveX *ax) : m_activeX(ax) {}
|
2003-03-25 06:35:27 +00:00
|
|
|
virtual ~wxActiveXEvents()
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//IDispatch
|
|
|
|
STDMETHODIMP GetIDsOfNames(REFIID r, OLECHAR** o, unsigned int i, LCID l, DISPID* d)
|
2003-03-25 06:35:27 +00:00
|
|
|
{
|
2002-07-11 17:43:34 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP GetTypeInfo(unsigned int i, LCID l, ITypeInfo** t)
|
2003-03-25 06:35:27 +00:00
|
|
|
{
|
2002-07-11 17:43:34 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP GetTypeInfoCount(unsigned int* i)
|
2003-03-25 06:35:27 +00:00
|
|
|
{
|
2002-07-11 17:43:34 +00:00
|
|
|
return E_NOTIMPL;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
void DispatchEvent(int eventIdx, const wxEventType& eventType, DISPPARAMS * pDispParams)
|
|
|
|
{
|
|
|
|
wxASSERT(eventIdx >= 0 && eventIdx < int(m_activeX->m_events.size()));
|
|
|
|
wxActiveX::FuncX &func = m_activeX->m_events[eventIdx];
|
2002-07-11 17:43:34 +00:00
|
|
|
|
|
|
|
wxActiveXEvent event;
|
|
|
|
event.SetId(m_activeX->GetId());
|
2002-08-08 18:29:59 +00:00
|
|
|
event.SetEventType(eventType);
|
2002-07-11 17:43:34 +00:00
|
|
|
event.m_params.NullList();
|
2002-08-08 18:29:59 +00:00
|
|
|
event.m_params.SetName(func.name);
|
2002-07-11 17:43:34 +00:00
|
|
|
|
|
|
|
// arguments
|
|
|
|
if (pDispParams)
|
|
|
|
{
|
|
|
|
// cdecl call
|
2002-08-08 18:29:59 +00:00
|
|
|
// sometimes the pDispParams does not match the param info for a activex control
|
|
|
|
int nArg = min(func.params.size(), pDispParams->cArgs);
|
|
|
|
for (int i = nArg - 1; i >= 0; i--)
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
|
|
|
VARIANTARG& va = pDispParams->rgvarg[i];
|
2002-08-08 18:29:59 +00:00
|
|
|
wxActiveX::ParamX &px = func.params[nArg - i - 1];
|
2002-07-11 17:43:34 +00:00
|
|
|
wxVariant vx;
|
|
|
|
|
|
|
|
vx.SetName(px.name);
|
2002-08-08 18:29:59 +00:00
|
|
|
MSWVariantToVariant(va, vx);
|
2002-07-11 17:43:34 +00:00
|
|
|
event.m_params.Append(vx);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
if (func.hasOut)
|
|
|
|
{
|
2002-08-08 18:29:59 +00:00
|
|
|
int nArg = min(func.params.size(), pDispParams->cArgs);
|
2002-07-11 17:43:34 +00:00
|
|
|
m_activeX->GetParent()->ProcessEvent(event);
|
2002-08-08 18:29:59 +00:00
|
|
|
for (int i = 0; i < nArg; i++)
|
2002-07-11 17:43:34 +00:00
|
|
|
{
|
|
|
|
VARIANTARG& va = pDispParams->rgvarg[i];
|
2002-08-08 18:29:59 +00:00
|
|
|
wxActiveX::ParamX &px = func.params[nArg - i - 1];
|
2002-07-11 17:43:34 +00:00
|
|
|
|
|
|
|
if (px.IsOut())
|
|
|
|
{
|
2002-08-08 18:29:59 +00:00
|
|
|
wxVariant& vx = event.m_params[nArg - i - 1];
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
VariantToMSWVariant(vx, va);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
else
|
|
|
|
m_activeX->GetParent()->AddPendingEvent(event);
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS * pDispParams,
|
|
|
|
VARIANT * pVarResult, EXCEPINFO * pExcepInfo,
|
|
|
|
unsigned int * puArgErr)
|
2003-03-25 06:35:27 +00:00
|
|
|
{
|
2002-08-08 18:29:59 +00:00
|
|
|
if (wFlags & (DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF))
|
|
|
|
return E_NOTIMPL;
|
|
|
|
|
|
|
|
wxASSERT(m_activeX);
|
|
|
|
|
|
|
|
// map dispid to m_eventsIdx
|
|
|
|
wxActiveX::MemberIdList::iterator mid = m_activeX->m_eventsIdx.find((MEMBERID) dispIdMember);
|
|
|
|
if (mid == m_activeX->m_eventsIdx.end())
|
|
|
|
return S_OK;
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
int funcIdx = mid->second;
|
2002-08-08 18:29:59 +00:00
|
|
|
wxActiveX::FuncX &func = m_activeX->m_events[funcIdx];
|
|
|
|
|
|
|
|
|
|
|
|
// try to find dispid event
|
|
|
|
ActiveXDISPIDEventMap::iterator dit = sg_dispIdEventMap.find(dispIdMember);
|
|
|
|
if (dit != sg_dispIdEventMap.end())
|
|
|
|
{
|
|
|
|
// Dispatch Event
|
|
|
|
DispatchEvent(funcIdx, *(dit->second), pDispParams);
|
|
|
|
return S_OK;
|
|
|
|
};
|
|
|
|
|
|
|
|
// try named event
|
|
|
|
ActiveXNamedEventMap::iterator nit = sg_NamedEventMap.find(func.name);
|
|
|
|
if (nit == sg_NamedEventMap.end())
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
// Dispatch Event
|
|
|
|
DispatchEvent(funcIdx, *(nit->second), pDispParams);
|
2002-07-11 17:43:34 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
DEFINE_OLE_TABLE(wxActiveXEvents)
|
|
|
|
OLE_IINTERFACE(IUnknown)
|
|
|
|
OLE_INTERFACE(IID_IDispatch, IDispatch)
|
|
|
|
END_OLE_TABLE;
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
wxString wxActiveXEvent::EventName()
|
|
|
|
{
|
|
|
|
return m_params.GetName();
|
|
|
|
};
|
2002-07-11 17:43:34 +00:00
|
|
|
|
|
|
|
int wxActiveXEvent::ParamCount() const
|
|
|
|
{
|
|
|
|
return m_params.GetCount();
|
|
|
|
};
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
wxString wxActiveXEvent::ParamType(int idx)
|
|
|
|
{
|
|
|
|
wxASSERT(idx >= 0 && idx < m_params.GetCount());
|
|
|
|
|
|
|
|
return m_params[idx].GetType();
|
|
|
|
};
|
|
|
|
|
|
|
|
wxString wxActiveXEvent::ParamName(int idx)
|
|
|
|
{
|
|
|
|
wxASSERT(idx >= 0 && idx < m_params.GetCount());
|
|
|
|
|
|
|
|
return m_params[idx].GetName();
|
|
|
|
};
|
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
static wxVariant nullVar;
|
|
|
|
|
|
|
|
wxVariant wxActiveXEvent::operator[] (int idx) const
|
|
|
|
{
|
|
|
|
return (wxVariant&) operator[] (idx);
|
|
|
|
};
|
|
|
|
|
|
|
|
wxVariant& wxActiveXEvent::operator[] (int idx)
|
|
|
|
{
|
|
|
|
wxASSERT(idx >= 0 && idx < ParamCount());
|
|
|
|
|
|
|
|
return m_params[idx];
|
|
|
|
};
|
|
|
|
|
|
|
|
wxVariant wxActiveXEvent::operator[] (wxString name) const
|
|
|
|
{
|
|
|
|
return (wxVariant&) operator[] (name);
|
|
|
|
};
|
|
|
|
|
|
|
|
wxVariant& wxActiveXEvent::operator[] (wxString name)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_params.GetCount(); i++)
|
|
|
|
{
|
|
|
|
if (name.CmpNoCase(m_params[i].GetName()) == 0)
|
|
|
|
return m_params[i];
|
|
|
|
};
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
wxString err = wxT("wxActiveXEvent::operator[] invalid name <") + name + wxT(">");
|
|
|
|
err += wxT("\r\nValid Names = :\r\n");
|
2002-07-11 17:43:34 +00:00
|
|
|
for (i = 0; i < m_params.GetCount(); i++)
|
|
|
|
{
|
|
|
|
err += m_params[i].GetName();
|
2003-03-25 06:35:27 +00:00
|
|
|
err += wxT("\r\n");
|
2002-07-11 17:43:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
wxASSERT_MSG(false, err);
|
|
|
|
|
|
|
|
return nullVar;
|
|
|
|
};
|
|
|
|
|
|
|
|
void wxActiveX::GetTypeInfo()
|
|
|
|
{
|
|
|
|
/*
|
2003-03-25 06:35:27 +00:00
|
|
|
We are currently only interested in the IDispatch interface
|
2002-07-11 17:43:34 +00:00
|
|
|
to the control. For dual interfaces (TypeKind = TKIND_INTERFACE)
|
2003-03-25 06:35:27 +00:00
|
|
|
we should drill down through the inheritance
|
2002-07-11 17:43:34 +00:00
|
|
|
(using TYPEATTR->cImplTypes) and GetRefTypeOfImplType(n)
|
2003-03-25 06:35:27 +00:00
|
|
|
and retrieve all the func names etc that way, then generate a C++
|
2002-07-11 17:43:34 +00:00
|
|
|
header file for it.
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
But we don't do this and probably never will, so if we have a DUAL
|
|
|
|
interface then we query for the IDispatch
|
2002-07-11 17:43:34 +00:00
|
|
|
via GetRefTypeOfImplType(-1).
|
|
|
|
*/
|
|
|
|
|
|
|
|
HRESULT hret = 0;
|
|
|
|
|
|
|
|
// get type info via class info
|
|
|
|
wxAutoOleInterface<IProvideClassInfo> classInfo(IID_IProvideClassInfo, m_ActiveX);
|
|
|
|
if (! classInfo.Ok())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// type info
|
|
|
|
wxAutoOleInterface<ITypeInfo> typeInfo;
|
|
|
|
hret = classInfo->GetClassInfo(typeInfo.GetRef());
|
|
|
|
if (! typeInfo.Ok())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// TYPEATTR
|
|
|
|
TYPEATTR *ta = NULL;
|
|
|
|
hret = typeInfo->GetTypeAttr(&ta);
|
|
|
|
if (! ta)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// this should be a TKIND_COCLASS
|
|
|
|
wxASSERT(ta->typekind == TKIND_COCLASS);
|
|
|
|
|
|
|
|
// iterate contained interfaces
|
|
|
|
for (int i = 0; i < ta->cImplTypes; i++)
|
|
|
|
{
|
|
|
|
HREFTYPE rt = 0;
|
|
|
|
|
|
|
|
// get dispatch type info handle
|
|
|
|
hret = typeInfo->GetRefTypeOfImplType(i, &rt);
|
|
|
|
if (! SUCCEEDED(hret))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// get dispatch type info interface
|
|
|
|
wxAutoOleInterface<ITypeInfo> ti;
|
|
|
|
hret = typeInfo->GetRefTypeInfo(rt, ti.GetRef());
|
|
|
|
if (! ti.Ok())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// check if default event sink
|
|
|
|
bool defEventSink = false;
|
|
|
|
int impTypeFlags = 0;
|
|
|
|
typeInfo->GetImplTypeFlags(i, &impTypeFlags);
|
|
|
|
|
|
|
|
if (impTypeFlags & IMPLTYPEFLAG_FDEFAULT)
|
|
|
|
{
|
|
|
|
if (impTypeFlags & IMPLTYPEFLAG_FSOURCE)
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
WXOLE_TRACEOUT(wxT("Default Event Sink"));
|
2002-07-11 17:43:34 +00:00
|
|
|
defEventSink = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
WXOLE_TRACEOUT(wxT("Default Interface"));
|
2002-07-11 17:43:34 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// process
|
|
|
|
GetTypeInfo(ti, defEventSink);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// free
|
|
|
|
typeInfo->ReleaseTypeAttr(ta);
|
|
|
|
};
|
|
|
|
|
|
|
|
void wxActiveX::GetTypeInfo(ITypeInfo *ti, bool defEventSink)
|
|
|
|
{
|
|
|
|
ti->AddRef();
|
|
|
|
wxAutoOleInterface<ITypeInfo> typeInfo(ti);
|
|
|
|
|
|
|
|
// TYPEATTR
|
|
|
|
TYPEATTR *ta = NULL;
|
|
|
|
HRESULT hret = typeInfo->GetTypeAttr(&ta);
|
|
|
|
if (! ta)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ta->typekind == TKIND_DISPATCH)
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
WXOLE_TRACEOUT(wxT("GUID = ") << GetIIDName(ta->guid).c_str());
|
2002-07-11 17:43:34 +00:00
|
|
|
|
|
|
|
if (defEventSink)
|
|
|
|
{
|
|
|
|
wxActiveXEvents *disp = new wxActiveXEvents(this);
|
|
|
|
ConnectAdvise(ta->guid, disp);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Get Function Names
|
|
|
|
for (int i = 0; i < ta->cFuncs; i++)
|
|
|
|
{
|
|
|
|
FUNCDESC FAR *fd = NULL;
|
|
|
|
|
|
|
|
hret = typeInfo->GetFuncDesc(i, &fd);
|
|
|
|
if (! fd)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
BSTR anames[1] = {NULL};
|
|
|
|
unsigned int n = 0;
|
|
|
|
|
|
|
|
hret = typeInfo->GetNames(fd->memid, anames, 1, &n);
|
|
|
|
|
|
|
|
if (anames[0])
|
|
|
|
{
|
|
|
|
wxString name = anames[0];
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
WXOLE_TRACEOUT(wxT("Name ") << i << wxT(" = ") << name.c_str());
|
2002-07-11 17:43:34 +00:00
|
|
|
SysFreeString(anames[0]);
|
|
|
|
|
|
|
|
if (defEventSink)
|
|
|
|
{
|
|
|
|
FuncX func;
|
|
|
|
func.name = name;
|
|
|
|
func.memid = fd->memid;
|
|
|
|
func.hasOut = false;
|
|
|
|
|
|
|
|
// get Param Names
|
|
|
|
unsigned int maxPNames = fd->cParams + 1;
|
|
|
|
unsigned int nPNames = 0;
|
|
|
|
BSTR *pnames = new BSTR[maxPNames];
|
|
|
|
|
|
|
|
hret = typeInfo->GetNames(fd->memid, pnames, maxPNames, &nPNames);
|
2002-08-08 18:29:59 +00:00
|
|
|
wxASSERT(int(nPNames) >= fd->cParams + 1);
|
2002-07-11 17:43:34 +00:00
|
|
|
|
|
|
|
SysFreeString(pnames[0]);
|
|
|
|
// params
|
|
|
|
for (int p = 0; p < fd->cParams; p++)
|
|
|
|
{
|
|
|
|
ParamX param;
|
2002-08-08 18:29:59 +00:00
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
param.flags = fd->lprgelemdescParam[p].idldesc.wIDLFlags;
|
|
|
|
param.vt = fd->lprgelemdescParam[p].tdesc.vt;
|
2002-08-08 18:29:59 +00:00
|
|
|
param.isPtr = (param.vt == VT_PTR);
|
|
|
|
param.isSafeArray = (param.vt == VT_SAFEARRAY);
|
|
|
|
if (param.isPtr || param.isSafeArray)
|
|
|
|
param.vt = fd->lprgelemdescParam[p].tdesc.lptdesc->vt;
|
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
param.name = pnames[p + 1];
|
|
|
|
SysFreeString(pnames[p + 1]);
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
func.hasOut |= (param.IsOut() || param.isPtr);
|
2002-07-11 17:43:34 +00:00
|
|
|
func.params.push_back(param);
|
|
|
|
};
|
|
|
|
delete [] pnames;
|
|
|
|
|
|
|
|
m_events.push_back(func);
|
|
|
|
m_eventsIdx[fd->memid] = m_events.size() - 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
typeInfo->ReleaseFuncDesc(fd);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
typeInfo->ReleaseTypeAttr(ta);
|
|
|
|
};
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
///////////////////////////////////////////////
|
|
|
|
// Type Info exposure
|
|
|
|
const wxActiveX::FuncX& wxActiveX::GetEvent(int idx) const
|
|
|
|
{
|
|
|
|
wxASSERT(idx >= 0 && idx < GetEventCount());
|
|
|
|
|
|
|
|
return m_events[idx];
|
|
|
|
};
|
|
|
|
|
|
|
|
///////////////////////////////////////////////
|
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
HRESULT wxActiveX::ConnectAdvise(REFIID riid, IUnknown *events)
|
|
|
|
{
|
|
|
|
wxOleConnectionPoint cp;
|
|
|
|
DWORD adviseCookie = 0;
|
|
|
|
|
|
|
|
wxAutoOleInterface<IConnectionPointContainer> cpContainer(IID_IConnectionPointContainer, m_ActiveX);
|
|
|
|
if (! cpContainer.Ok())
|
|
|
|
return E_FAIL;
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
HRESULT hret = cpContainer->FindConnectionPoint(riid, cp.GetRef());
|
|
|
|
if (! SUCCEEDED(hret))
|
|
|
|
return hret;
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
hret = cp->Advise(events, &adviseCookie);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hret))
|
|
|
|
m_connections.push_back(wxOleConnection(cp, adviseCookie));
|
|
|
|
|
|
|
|
return hret;
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT wxActiveX::AmbientPropertyChanged(DISPID dispid)
|
|
|
|
{
|
|
|
|
wxAutoOleInterface<IOleControl> oleControl(IID_IOleControl, m_oleObject);
|
|
|
|
|
|
|
|
if (oleControl.Ok())
|
|
|
|
return oleControl->OnAmbientPropertyChange(dispid);
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HIMETRIC_PER_INCH 2540
|
|
|
|
#define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
|
|
|
|
|
|
|
|
static void PixelsToHimetric(SIZEL &sz)
|
|
|
|
{
|
|
|
|
static int logX = 0;
|
|
|
|
static int logY = 0;
|
|
|
|
|
|
|
|
if (logY == 0)
|
|
|
|
{
|
|
|
|
// initaliase
|
|
|
|
HDC dc = GetDC(NULL);
|
|
|
|
logX = GetDeviceCaps(dc, LOGPIXELSX);
|
|
|
|
logY = GetDeviceCaps(dc, LOGPIXELSY);
|
|
|
|
ReleaseDC(NULL, dc);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HIMETRIC_INCH 2540
|
|
|
|
#define CONVERT(x, logpixels) MulDiv(HIMETRIC_INCH, (x), (logpixels))
|
|
|
|
|
|
|
|
sz.cx = CONVERT(sz.cx, logX);
|
|
|
|
sz.cy = CONVERT(sz.cy, logY);
|
|
|
|
|
|
|
|
#undef CONVERT
|
|
|
|
#undef HIMETRIC_INCH
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wxActiveX::OnSize(wxSizeEvent& event)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
GetClientSize(&w, &h);
|
|
|
|
|
|
|
|
RECT posRect;
|
|
|
|
posRect.left = 0;
|
|
|
|
posRect.top = 0;
|
|
|
|
posRect.right = w;
|
|
|
|
posRect.bottom = h;
|
|
|
|
|
2002-07-11 17:43:34 +00:00
|
|
|
if (w <= 0 && h <= 0)
|
|
|
|
return;
|
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
// extents are in HIMETRIC units
|
2002-07-20 00:06:59 +00:00
|
|
|
if (m_oleObject.Ok())
|
|
|
|
{
|
|
|
|
SIZEL sz = {w, h};
|
|
|
|
PixelsToHimetric(sz);
|
2002-07-03 22:05:30 +00:00
|
|
|
|
2002-07-20 00:06:59 +00:00
|
|
|
SIZEL sz2;
|
|
|
|
|
|
|
|
m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2);
|
|
|
|
if (sz2.cx != sz.cx || sz.cy != sz2.cy)
|
|
|
|
m_oleObject->SetExtent(DVASPECT_CONTENT, &sz);
|
|
|
|
};
|
2002-08-08 18:29:59 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if (m_oleInPlaceObject.Ok())
|
2002-08-08 18:29:59 +00:00
|
|
|
m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxActiveX::OnPaint(wxPaintEvent& event)
|
|
|
|
{
|
2004-01-14 01:51:52 +00:00
|
|
|
// wxLogTrace(wxT("repainting activex win"));
|
2002-08-08 18:29:59 +00:00
|
|
|
wxPaintDC dc(this);
|
|
|
|
dc.BeginDrawing();
|
|
|
|
int w, h;
|
|
|
|
GetSize(&w, &h);
|
|
|
|
RECT posRect;
|
|
|
|
posRect.left = 0;
|
|
|
|
posRect.top = 0;
|
|
|
|
posRect.right = w;
|
|
|
|
posRect.bottom = h;
|
|
|
|
|
|
|
|
// Draw only when control is windowless or deactivated
|
|
|
|
if (m_viewObject)
|
|
|
|
{
|
|
|
|
::RedrawWindow(m_oleObjectHWND, NULL, NULL, RDW_INTERNALPAINT);
|
|
|
|
{
|
|
|
|
RECTL *prcBounds = (RECTL *) &posRect;
|
2003-03-25 06:35:27 +00:00
|
|
|
m_viewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL,
|
2002-08-08 18:29:59 +00:00
|
|
|
(HDC)dc.GetHDC(), prcBounds, NULL, NULL, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dc.SetBrush(*wxRED_BRUSH);
|
|
|
|
dc.DrawRectangle(0, 0, w, h);
|
|
|
|
dc.SetBrush(wxNullBrush);
|
|
|
|
}
|
|
|
|
dc.EndDrawing();
|
2002-07-03 22:05:30 +00:00
|
|
|
}
|
|
|
|
|
2002-08-08 18:29:59 +00:00
|
|
|
|
|
|
|
void wxActiveX::OnMouse(wxMouseEvent& event)
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
if (m_oleObjectHWND == NULL)
|
|
|
|
{
|
2004-01-14 01:51:52 +00:00
|
|
|
// wxLogTrace(wxT("no oleInPlaceObject"));
|
2003-03-25 06:35:27 +00:00
|
|
|
event.Skip();
|
|
|
|
return;
|
2002-08-08 18:29:59 +00:00
|
|
|
}
|
|
|
|
|
2004-01-14 01:51:52 +00:00
|
|
|
// wxLogTrace(wxT("mouse event"));
|
2002-08-08 18:29:59 +00:00
|
|
|
UINT msg = 0;
|
|
|
|
WPARAM wParam = 0;
|
|
|
|
LPARAM lParam = 0;
|
|
|
|
LRESULT lResult = 0;
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if (event.m_metaDown)
|
2002-08-08 18:29:59 +00:00
|
|
|
wParam |= MK_CONTROL;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (event.m_shiftDown)
|
2002-08-08 18:29:59 +00:00
|
|
|
wParam |= MK_SHIFT;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (event.m_leftDown)
|
2002-08-08 18:29:59 +00:00
|
|
|
wParam |= MK_LBUTTON;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (event.m_middleDown)
|
2002-08-08 18:29:59 +00:00
|
|
|
wParam |= MK_MBUTTON;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (event.m_rightDown)
|
2002-08-08 18:29:59 +00:00
|
|
|
wParam |= MK_RBUTTON;
|
|
|
|
lParam = event.m_x << 16;
|
|
|
|
lParam |= event.m_y;
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if (event.LeftDown())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_LBUTTONDOWN;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.LeftDClick())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_LBUTTONDBLCLK;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.LeftUp())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_LBUTTONUP;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.MiddleDown())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_MBUTTONDOWN;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.MiddleDClick())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_MBUTTONDBLCLK;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.MiddleUp())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_MBUTTONUP;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.RightDown())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_RBUTTONDOWN;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.RightDClick())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_RBUTTONDBLCLK;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.RightUp())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_RBUTTONUP;
|
2003-03-25 06:35:27 +00:00
|
|
|
else if (event.Moving() || event.Dragging())
|
2002-08-08 18:29:59 +00:00
|
|
|
msg = WM_MOUSEMOVE;
|
|
|
|
|
|
|
|
wxString log;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (msg == 0)
|
|
|
|
{
|
2004-01-14 01:51:52 +00:00
|
|
|
// wxLogTrace(wxT("no message"));
|
2003-03-25 06:35:27 +00:00
|
|
|
event.Skip(); return;
|
2002-08-08 18:29:59 +00:00
|
|
|
};
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if (!::SendMessage(m_oleObjectHWND, msg, wParam, lParam))
|
|
|
|
{
|
2004-01-14 01:51:52 +00:00
|
|
|
// wxLogTrace(wxT("msg not delivered"));
|
2003-03-25 06:35:27 +00:00
|
|
|
event.Skip();
|
|
|
|
return;
|
2002-08-08 18:29:59 +00:00
|
|
|
};
|
|
|
|
|
2004-01-14 01:51:52 +00:00
|
|
|
// wxLogTrace(wxT("msg sent"));
|
2002-08-08 18:29:59 +00:00
|
|
|
}
|
|
|
|
|
2004-02-25 10:45:02 +00:00
|
|
|
WXLRESULT wxActiveX::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
2002-08-08 18:29:59 +00:00
|
|
|
{
|
|
|
|
if (m_oleObjectHWND == NULL)
|
|
|
|
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
|
|
|
|
|
|
|
switch(nMsg)
|
|
|
|
{
|
|
|
|
case WM_CHAR:
|
|
|
|
case WM_DEADCHAR:
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSCHAR:
|
|
|
|
case WM_SYSDEADCHAR:
|
|
|
|
case WM_SYSKEYDOWN:
|
|
|
|
case WM_SYSKEYUP:
|
|
|
|
PostMessage(m_oleObjectHWND, nMsg, wParam, lParam);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
void wxActiveX::OnSetFocus(wxFocusEvent& event)
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
if (m_oleInPlaceActiveObject.Ok())
|
2002-07-03 22:05:30 +00:00
|
|
|
m_oleInPlaceActiveObject->OnFrameWindowActivate(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void wxActiveX::OnKillFocus(wxFocusEvent& event)
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
if (m_oleInPlaceActiveObject.Ok())
|
2002-07-03 22:05:30 +00:00
|
|
|
m_oleInPlaceActiveObject->OnFrameWindowActivate(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FrameSite::FrameSite(wxActiveX * win)
|
|
|
|
{
|
|
|
|
m_window = win;
|
|
|
|
m_bSupportsWindowlessActivation = true;
|
|
|
|
m_bInPlaceLocked = false;
|
|
|
|
m_bUIActive = false;
|
|
|
|
m_bInPlaceActive = false;
|
|
|
|
m_bWindowless = false;
|
|
|
|
|
|
|
|
m_nAmbientLocale = 0;
|
|
|
|
m_clrAmbientForeColor = ::GetSysColor(COLOR_WINDOWTEXT);
|
|
|
|
m_clrAmbientBackColor = ::GetSysColor(COLOR_WINDOW);
|
|
|
|
m_bAmbientShowHatching = true;
|
|
|
|
m_bAmbientShowGrabHandles = true;
|
|
|
|
m_bAmbientAppearance = true;
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
m_hDCBuffer = NULL;
|
|
|
|
m_hWndParent = (HWND)m_window->GetHWND();
|
|
|
|
}
|
|
|
|
|
|
|
|
FrameSite::~FrameSite()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//IDispatch
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetIDsOfNames(REFIID riid, OLECHAR ** rgszNames, unsigned int cNames,
|
|
|
|
LCID lcid, DISPID * rgDispId)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IDispatch::GetIDsOfNames");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetTypeInfo(unsigned int iTInfo, LCID lcid, ITypeInfo ** ppTInfo)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IDispatch::GetTypeInfo");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetTypeInfoCount(unsigned int * pcTInfo)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IDispatch::GetTypeInfoCount");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid,
|
|
|
|
WORD wFlags, DISPPARAMS * pDispParams,
|
|
|
|
VARIANT * pVarResult, EXCEPINFO * pExcepInfo,
|
|
|
|
unsigned int * puArgErr)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IDispatch::Invoke");
|
|
|
|
|
|
|
|
if (!(wFlags & DISPATCH_PROPERTYGET))
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
HRESULT hr;
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
if (pVarResult == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
//The most common case is boolean, use as an initial type
|
|
|
|
V_VT(pVarResult) = VT_BOOL;
|
|
|
|
|
|
|
|
switch (dispIdMember)
|
|
|
|
{
|
|
|
|
case DISPID_AMBIENT_MESSAGEREFLECT:
|
|
|
|
WXOLE_TRACE("Invoke::DISPID_AMBIENT_MESSAGEREFLECT");
|
|
|
|
V_BOOL(pVarResult)= FALSE;
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_DISPLAYASDEFAULT:
|
|
|
|
WXOLE_TRACE("Invoke::DISPID_AMBIENT_DISPLAYASDEFAULT");
|
|
|
|
V_BOOL(pVarResult)= TRUE;
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
|
|
|
|
WXOLE_TRACE("Invoke::DISPID_AMBIENT_OFFLINEIFNOTCONNECTED");
|
|
|
|
V_BOOL(pVarResult) = TRUE;
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_SILENT:
|
|
|
|
WXOLE_TRACE("Invoke::DISPID_AMBIENT_SILENT");
|
|
|
|
V_BOOL(pVarResult)= TRUE;
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_APPEARANCE:
|
|
|
|
pVarResult->vt = VT_BOOL;
|
|
|
|
pVarResult->boolVal = m_bAmbientAppearance;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_FORECOLOR:
|
|
|
|
pVarResult->vt = VT_I4;
|
|
|
|
pVarResult->lVal = (long) m_clrAmbientForeColor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_BACKCOLOR:
|
|
|
|
pVarResult->vt = VT_I4;
|
|
|
|
pVarResult->lVal = (long) m_clrAmbientBackColor;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_LOCALEID:
|
|
|
|
pVarResult->vt = VT_I4;
|
|
|
|
pVarResult->lVal = (long) m_nAmbientLocale;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_USERMODE:
|
|
|
|
pVarResult->vt = VT_BOOL;
|
|
|
|
pVarResult->boolVal = m_window->m_bAmbientUserMode;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_SHOWGRABHANDLES:
|
|
|
|
pVarResult->vt = VT_BOOL;
|
|
|
|
pVarResult->boolVal = m_bAmbientShowGrabHandles;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DISPID_AMBIENT_SHOWHATCHING:
|
|
|
|
pVarResult->vt = VT_BOOL;
|
|
|
|
pVarResult->boolVal = m_bAmbientShowHatching;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return DISP_E_MEMBERNOTFOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleWindow
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetWindow(HWND * phwnd)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleWindow::GetWindow");
|
2003-03-25 06:35:27 +00:00
|
|
|
if (phwnd == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
(*phwnd) = m_hWndParent;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::ContextSensitiveHelp(BOOL fEnterMode)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleWindow::ContextSensitiveHelp");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleInPlaceUIWindow
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetBorder(LPRECT lprectBorder)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceUIWindow::GetBorder");
|
2003-03-25 06:35:27 +00:00
|
|
|
if (lprectBorder == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
return INPLACE_E_NOTOOLSPACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::RequestBorderSpace(LPCBORDERWIDTHS pborderwidths)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceUIWindow::RequestBorderSpace");
|
2003-03-25 06:35:27 +00:00
|
|
|
if (pborderwidths == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
return INPLACE_E_NOTOOLSPACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::SetBorderSpace(LPCBORDERWIDTHS pborderwidths)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceUIWindow::SetBorderSpace");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::SetActiveObject(IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceUIWindow::SetActiveObject");
|
|
|
|
|
|
|
|
if (pActiveObject)
|
|
|
|
pActiveObject->AddRef();
|
|
|
|
|
|
|
|
m_window->m_oleInPlaceActiveObject = pActiveObject;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleInPlaceFrame
|
|
|
|
|
|
|
|
HRESULT FrameSite::InsertMenus(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceFrame::InsertMenus");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::SetMenu(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceFrame::SetMenu");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::RemoveMenus(HMENU hmenuShared)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceFrame::RemoveMenus");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::SetStatusText(LPCOLESTR pszStatusText)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceFrame::SetStatusText");
|
|
|
|
//((wxFrame*)wxGetApp().GetTopWindow())->GetStatusBar()->SetStatusText(pszStatusText);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::EnableModeless(BOOL fEnable)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceFrame::EnableModeless");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::TranslateAccelerator(LPMSG lpmsg, WORD wID)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceFrame::TranslateAccelerator");
|
|
|
|
// TODO: send an event with this id
|
|
|
|
if (m_window->m_oleInPlaceActiveObject.Ok())
|
|
|
|
m_window->m_oleInPlaceActiveObject->TranslateAccelerator(lpmsg);
|
|
|
|
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleInPlaceSite
|
|
|
|
|
|
|
|
HRESULT FrameSite::CanInPlaceActivate()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::CanInPlaceActivate");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnInPlaceActivate()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::OnInPlaceActivate");
|
|
|
|
m_bInPlaceActive = true;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnUIActivate()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::OnUIActivate");
|
|
|
|
m_bUIActive = true;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetWindowContext(IOleInPlaceFrame **ppFrame,
|
|
|
|
IOleInPlaceUIWindow **ppDoc,
|
|
|
|
LPRECT lprcPosRect,
|
|
|
|
LPRECT lprcClipRect,
|
|
|
|
LPOLEINPLACEFRAMEINFO lpFrameInfo)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::GetWindowContext");
|
|
|
|
if (ppFrame == NULL || ppDoc == NULL || lprcPosRect == NULL ||
|
|
|
|
lprcClipRect == NULL || lpFrameInfo == NULL)
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
if (ppFrame != NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
(*ppFrame) = NULL;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (ppDoc != NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
(*ppDoc) = NULL;
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT hr = QueryInterface(IID_IOleInPlaceFrame, (void **) ppFrame);
|
|
|
|
if (! SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceFrame Error !");
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
hr = QueryInterface(IID_IOleInPlaceUIWindow, (void **) ppDoc);
|
|
|
|
if (! SUCCEEDED(hr))
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceUIWindow Error !");
|
|
|
|
(*ppFrame)->Release();
|
|
|
|
*ppFrame = NULL;
|
|
|
|
return E_UNEXPECTED;
|
|
|
|
};
|
|
|
|
|
|
|
|
int w, h;
|
|
|
|
m_window->GetClientSize(&w, &h);
|
|
|
|
if (lprcPosRect)
|
|
|
|
{
|
|
|
|
lprcPosRect->left = lprcPosRect->top = 0;
|
|
|
|
lprcPosRect->right = w;
|
|
|
|
lprcPosRect->bottom = h;
|
|
|
|
};
|
|
|
|
if (lprcClipRect)
|
|
|
|
{
|
|
|
|
lprcClipRect->left = lprcClipRect->top = 0;
|
|
|
|
lprcClipRect->right = w;
|
|
|
|
lprcClipRect->bottom = h;
|
|
|
|
};
|
|
|
|
|
|
|
|
memset(lpFrameInfo, 0, sizeof(OLEINPLACEFRAMEINFO));
|
|
|
|
lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO);
|
|
|
|
lpFrameInfo->hwndFrame = m_hWndParent;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::Scroll(SIZE scrollExtent)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::Scroll");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnUIDeactivate(BOOL fUndoable)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::OnUIDeactivate");
|
|
|
|
m_bUIActive = false;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnInPlaceDeactivate()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::OnInPlaceDeactivate");
|
|
|
|
m_bInPlaceActive = false;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::DiscardUndoState()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::DiscardUndoState");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::DeactivateAndUndo()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::DeactivateAndUndo");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnPosRectChange(LPCRECT lprcPosRect)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSite::OnPosRectChange");
|
|
|
|
if (m_window->m_oleInPlaceObject.Ok() && lprcPosRect)
|
|
|
|
m_window->m_oleInPlaceObject->SetObjectRects(lprcPosRect, lprcPosRect);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleInPlaceSiteEx
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnInPlaceActivateEx(BOOL * pfNoRedraw, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceActivateEx");
|
|
|
|
OleLockRunning(m_window->m_ActiveX, TRUE, FALSE);
|
2003-03-25 06:35:27 +00:00
|
|
|
if (pfNoRedraw)
|
2002-07-03 22:05:30 +00:00
|
|
|
(*pfNoRedraw) = FALSE;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnInPlaceDeactivateEx(BOOL fNoRedraw)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceDeactivateEx");
|
|
|
|
OleLockRunning(m_window->m_ActiveX, FALSE, FALSE);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::RequestUIActivate()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleInPlaceSiteEx::RequestUIActivate");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//IOleClientSite
|
|
|
|
|
|
|
|
HRESULT FrameSite::SaveObject()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleClientSite::SaveObject");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
|
|
|
|
IMoniker ** ppmk)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleClientSite::GetMoniker");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetContainer(LPOLECONTAINER * ppContainer)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleClientSite::GetContainer");
|
2003-03-25 06:35:27 +00:00
|
|
|
if (ppContainer == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
2003-03-25 06:35:27 +00:00
|
|
|
|
2002-07-03 22:05:30 +00:00
|
|
|
HRESULT hr = QueryInterface(IID_IOleContainer, (void**)(ppContainer));
|
|
|
|
wxASSERT(SUCCEEDED(hr));
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::ShowObject()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleClientSite::ShowObject");
|
2002-07-11 17:43:34 +00:00
|
|
|
if (m_window->m_oleObjectHWND)
|
|
|
|
::ShowWindow(m_window->m_oleObjectHWND, SW_SHOW);
|
2002-07-03 22:05:30 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnShowWindow(BOOL fShow)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleClientSite::OnShowWindow");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::RequestNewObjectLayout()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleClientSite::RequestNewObjectLayout");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IParseDisplayName
|
|
|
|
|
|
|
|
HRESULT FrameSite::ParseDisplayName(IBindCtx *pbc, LPOLESTR pszDisplayName,
|
|
|
|
ULONG *pchEaten, IMoniker **ppmkOut)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IParseDisplayName::ParseDisplayName");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleContainer
|
|
|
|
|
|
|
|
HRESULT FrameSite::EnumObjects(DWORD grfFlags, IEnumUnknown **ppenum)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleContainer::EnumObjects");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::LockContainer(BOOL fLock)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleContainer::LockContainer");
|
|
|
|
// TODO
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleItemContainer
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
HRESULT FrameSite::GetObject(LPOLESTR pszItem, DWORD dwSpeedNeeded,
|
2002-07-03 22:05:30 +00:00
|
|
|
IBindCtx * pbc, REFIID riid, void ** ppvObject)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleItemContainer::GetObject");
|
2003-03-25 06:35:27 +00:00
|
|
|
if (pszItem == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (ppvObject == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppvObject = NULL;
|
|
|
|
return MK_E_NOOBJECT;
|
|
|
|
}
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
HRESULT FrameSite::GetObjectStorage(LPOLESTR pszItem, IBindCtx * pbc,
|
2002-07-03 22:05:30 +00:00
|
|
|
REFIID riid, void ** ppvStorage)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleItemContainer::GetObjectStorage");
|
2003-03-25 06:35:27 +00:00
|
|
|
if (pszItem == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
2003-03-25 06:35:27 +00:00
|
|
|
if (ppvStorage == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppvStorage = NULL;
|
|
|
|
return MK_E_NOOBJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::IsRunning(LPOLESTR pszItem)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleItemContainer::IsRunning");
|
2003-03-25 06:35:27 +00:00
|
|
|
if (pszItem == NULL)
|
2002-07-03 22:05:30 +00:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return MK_E_NOOBJECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//IOleControlSite
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnControlInfoChanged()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleControlSite::OnControlInfoChanged");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::LockInPlaceActive(BOOL fLock)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleControlSite::LockInPlaceActive");
|
|
|
|
m_bInPlaceLocked = (fLock) ? true : false;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::GetExtendedControl(IDispatch ** ppDisp)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleControlSite::GetExtendedControl");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::TransformCoords(POINTL * pPtlHimetric, POINTF * pPtfContainer, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleControlSite::TransformCoords");
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (pPtlHimetric == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (pPtfContainer == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::TranslateAccelerator(LPMSG pMsg, DWORD grfModifiers)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleControlSite::TranslateAccelerator");
|
|
|
|
// TODO: send an event with this id
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::OnFocus(BOOL fGotFocus)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleControlSite::OnFocus");
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT FrameSite::ShowPropertyFrame()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleControlSite::ShowPropertyFrame");
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IOleCommandTarget
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
HRESULT FrameSite::QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds,
|
2002-07-03 22:05:30 +00:00
|
|
|
OLECMD * prgCmds, OLECMDTEXT * pCmdTet)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleCommandTarget::QueryStatus");
|
|
|
|
if (prgCmds == NULL) return E_INVALIDARG;
|
|
|
|
bool bCmdGroupFound = false;
|
|
|
|
|
|
|
|
for (ULONG nCmd = 0; nCmd < cCmds; nCmd++)
|
|
|
|
{
|
|
|
|
// unsupported by default
|
|
|
|
prgCmds[nCmd].cmdf = 0;
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; }
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
HRESULT FrameSite::Exec(const GUID * pguidCmdGroup, DWORD nCmdID,
|
|
|
|
DWORD nCmdExecOpt, VARIANTARG * pVaIn,
|
2002-07-03 22:05:30 +00:00
|
|
|
VARIANTARG * pVaOut)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IOleCommandTarget::Exec");
|
|
|
|
bool bCmdGroupFound = false;
|
|
|
|
|
|
|
|
if (!bCmdGroupFound) { OLECMDERR_E_UNKNOWNGROUP; }
|
|
|
|
return OLECMDERR_E_NOTSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
//IAdviseSink
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE FrameSite::OnDataChange(FORMATETC * pFormatEtc, STGMEDIUM * pgStgMed)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IAdviseSink::OnDataChange");
|
|
|
|
}
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE FrameSite::OnViewChange(DWORD dwAspect, LONG lIndex)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IAdviseSink::OnViewChange");
|
|
|
|
// redraw the control
|
|
|
|
}
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE FrameSite::OnRename(IMoniker * pmk)
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IAdviseSink::OnRename");
|
|
|
|
}
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE FrameSite::OnSave()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IAdviseSink::OnSave");
|
|
|
|
}
|
|
|
|
|
|
|
|
void STDMETHODCALLTYPE FrameSite::OnClose()
|
|
|
|
{
|
|
|
|
WXOLE_TRACE("IAdviseSink::OnClose");
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////
|
|
|
|
// IOleDocumentSite
|
|
|
|
HRESULT STDMETHODCALLTYPE FrameSite::ActivateMe(
|
|
|
|
/* [in] */ IOleDocumentView __RPC_FAR *pViewToActivate)
|
|
|
|
{
|
|
|
|
wxAutoOleInterface<IOleInPlaceSite> inPlaceSite(IID_IOleInPlaceSite, (IDispatch *) this);
|
|
|
|
if (!inPlaceSite.Ok())
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
if (pViewToActivate)
|
|
|
|
{
|
|
|
|
m_window->m_docView = pViewToActivate;
|
|
|
|
m_window->m_docView->SetInPlaceSite(inPlaceSite);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wxAutoOleInterface<IOleDocument> oleDoc(IID_IOleDocument, m_window->m_oleObject);
|
|
|
|
if (! oleDoc.Ok())
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
HRESULT hr = oleDoc->CreateView(inPlaceSite, NULL, 0, m_window->m_docView.GetRef());
|
|
|
|
if (hr != S_OK)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
m_window->m_docView->SetInPlaceSite(inPlaceSite);
|
|
|
|
};
|
|
|
|
|
|
|
|
m_window->m_docView->UIActivate(TRUE);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static IMalloc *iMalloc = NULL;
|
|
|
|
|
|
|
|
IMalloc *wxOleInit::GetIMalloc()
|
|
|
|
{
|
|
|
|
assert(iMalloc);
|
|
|
|
return iMalloc;
|
|
|
|
};
|
|
|
|
|
|
|
|
wxOleInit::wxOleInit()
|
|
|
|
{
|
|
|
|
if (OleInitialize(NULL) == S_OK && iMalloc == NULL)
|
|
|
|
CoGetMalloc(1, &iMalloc);
|
|
|
|
else if (iMalloc)
|
|
|
|
iMalloc->AddRef();
|
|
|
|
};
|
|
|
|
|
|
|
|
wxOleInit::~wxOleInit()
|
|
|
|
{
|
|
|
|
if (iMalloc)
|
|
|
|
{
|
|
|
|
if (iMalloc->Release() == 0)
|
|
|
|
iMalloc = NULL;
|
|
|
|
};
|
|
|
|
|
|
|
|
OleUninitialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString OLEHResultToString(HRESULT hr)
|
|
|
|
{
|
|
|
|
switch (hr)
|
|
|
|
{
|
|
|
|
case S_OK:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxEmptyString;
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case OLECMDERR_E_UNKNOWNGROUP:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("The pguidCmdGroup parameter is not NULL but does not specify a recognized command group.");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case OLECMDERR_E_NOTSUPPORTED:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup.");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case OLECMDERR_E_DISABLED:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("The command identified by nCmdID is currently disabled and cannot be executed.");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case OLECMDERR_E_NOHELP:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("The caller has asked for help on the command identified by nCmdID, but no help is available.");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case OLECMDERR_E_CANCELED:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("The user canceled the execution of the command.");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case E_INVALIDARG:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("E_INVALIDARG");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case E_OUTOFMEMORY:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("E_OUTOFMEMORY");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case E_NOINTERFACE:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("E_NOINTERFACE");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case E_UNEXPECTED:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("E_UNEXPECTED");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case STG_E_INVALIDFLAG:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("STG_E_INVALIDFLAG");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case E_FAIL:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("E_FAIL");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
case E_NOTIMPL:
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("E_NOTIMPL");
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
wxString buf;
|
|
|
|
buf.Printf(wxT("Unknown - 0x%X"), hr);
|
|
|
|
return buf;
|
2002-07-03 22:05:30 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
// borrowed from src/msw/ole/oleutils.cpp
|
|
|
|
wxString GetIIDName(REFIID riid)
|
|
|
|
{
|
|
|
|
// an association between symbolic name and numeric value of an IID
|
2003-03-25 06:35:27 +00:00
|
|
|
struct KNOWN_IID
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
|
|
|
const IID *pIid;
|
|
|
|
const wxChar *szName;
|
|
|
|
};
|
|
|
|
|
|
|
|
// construct the table containing all known interfaces
|
|
|
|
#define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }
|
2002-07-11 17:43:34 +00:00
|
|
|
#define ADD_KNOWN_GUID(name) { &name, _T(#name) }
|
2002-07-03 22:05:30 +00:00
|
|
|
|
2003-03-25 06:35:27 +00:00
|
|
|
static const KNOWN_IID aKnownIids[] =
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
|
|
|
ADD_KNOWN_IID(AdviseSink),
|
|
|
|
ADD_KNOWN_IID(AdviseSink2),
|
|
|
|
ADD_KNOWN_IID(BindCtx),
|
|
|
|
ADD_KNOWN_IID(ClassFactory),
|
|
|
|
#if ( !defined( __VISUALC__) || (__VISUALC__!=1010) ) && !defined(__MWERKS__)
|
|
|
|
ADD_KNOWN_IID(ContinueCallback),
|
|
|
|
ADD_KNOWN_IID(EnumOleDocumentViews),
|
|
|
|
ADD_KNOWN_IID(OleCommandTarget),
|
|
|
|
ADD_KNOWN_IID(OleDocument),
|
|
|
|
ADD_KNOWN_IID(OleDocumentSite),
|
|
|
|
ADD_KNOWN_IID(OleDocumentView),
|
|
|
|
ADD_KNOWN_IID(Print),
|
|
|
|
#endif
|
|
|
|
ADD_KNOWN_IID(DataAdviseHolder),
|
|
|
|
ADD_KNOWN_IID(DataObject),
|
|
|
|
ADD_KNOWN_IID(Debug),
|
|
|
|
ADD_KNOWN_IID(DebugStream),
|
|
|
|
ADD_KNOWN_IID(DfReserved1),
|
|
|
|
ADD_KNOWN_IID(DfReserved2),
|
|
|
|
ADD_KNOWN_IID(DfReserved3),
|
|
|
|
ADD_KNOWN_IID(Dispatch),
|
|
|
|
ADD_KNOWN_IID(DropSource),
|
|
|
|
ADD_KNOWN_IID(DropTarget),
|
|
|
|
ADD_KNOWN_IID(EnumCallback),
|
|
|
|
ADD_KNOWN_IID(EnumFORMATETC),
|
|
|
|
ADD_KNOWN_IID(EnumGeneric),
|
|
|
|
ADD_KNOWN_IID(EnumHolder),
|
|
|
|
ADD_KNOWN_IID(EnumMoniker),
|
|
|
|
ADD_KNOWN_IID(EnumOLEVERB),
|
|
|
|
ADD_KNOWN_IID(EnumSTATDATA),
|
|
|
|
ADD_KNOWN_IID(EnumSTATSTG),
|
|
|
|
ADD_KNOWN_IID(EnumString),
|
|
|
|
ADD_KNOWN_IID(EnumUnknown),
|
|
|
|
ADD_KNOWN_IID(EnumVARIANT),
|
|
|
|
ADD_KNOWN_IID(ExternalConnection),
|
|
|
|
ADD_KNOWN_IID(InternalMoniker),
|
|
|
|
ADD_KNOWN_IID(LockBytes),
|
|
|
|
ADD_KNOWN_IID(Malloc),
|
|
|
|
ADD_KNOWN_IID(Marshal),
|
|
|
|
ADD_KNOWN_IID(MessageFilter),
|
|
|
|
ADD_KNOWN_IID(Moniker),
|
|
|
|
ADD_KNOWN_IID(OleAdviseHolder),
|
|
|
|
ADD_KNOWN_IID(OleCache),
|
|
|
|
ADD_KNOWN_IID(OleCache2),
|
|
|
|
ADD_KNOWN_IID(OleCacheControl),
|
|
|
|
ADD_KNOWN_IID(OleClientSite),
|
|
|
|
ADD_KNOWN_IID(OleContainer),
|
|
|
|
ADD_KNOWN_IID(OleInPlaceActiveObject),
|
|
|
|
ADD_KNOWN_IID(OleInPlaceFrame),
|
|
|
|
ADD_KNOWN_IID(OleInPlaceObject),
|
|
|
|
ADD_KNOWN_IID(OleInPlaceSite),
|
|
|
|
ADD_KNOWN_IID(OleInPlaceUIWindow),
|
|
|
|
ADD_KNOWN_IID(OleItemContainer),
|
|
|
|
ADD_KNOWN_IID(OleLink),
|
|
|
|
ADD_KNOWN_IID(OleManager),
|
|
|
|
ADD_KNOWN_IID(OleObject),
|
|
|
|
ADD_KNOWN_IID(OlePresObj),
|
|
|
|
ADD_KNOWN_IID(OleWindow),
|
|
|
|
ADD_KNOWN_IID(PSFactory),
|
|
|
|
ADD_KNOWN_IID(ParseDisplayName),
|
|
|
|
ADD_KNOWN_IID(Persist),
|
|
|
|
ADD_KNOWN_IID(PersistFile),
|
|
|
|
ADD_KNOWN_IID(PersistStorage),
|
|
|
|
ADD_KNOWN_IID(PersistStream),
|
|
|
|
ADD_KNOWN_IID(ProxyManager),
|
|
|
|
ADD_KNOWN_IID(RootStorage),
|
|
|
|
ADD_KNOWN_IID(RpcChannel),
|
|
|
|
ADD_KNOWN_IID(RpcProxy),
|
|
|
|
ADD_KNOWN_IID(RpcStub),
|
|
|
|
ADD_KNOWN_IID(RunnableObject),
|
|
|
|
ADD_KNOWN_IID(RunningObjectTable),
|
|
|
|
ADD_KNOWN_IID(StdMarshalInfo),
|
|
|
|
ADD_KNOWN_IID(Storage),
|
|
|
|
ADD_KNOWN_IID(Stream),
|
|
|
|
ADD_KNOWN_IID(StubManager),
|
|
|
|
ADD_KNOWN_IID(Unknown),
|
|
|
|
ADD_KNOWN_IID(ViewObject),
|
|
|
|
ADD_KNOWN_IID(ViewObject2),
|
2002-07-11 17:43:34 +00:00
|
|
|
ADD_KNOWN_GUID(IID_IDispatch),
|
|
|
|
ADD_KNOWN_GUID(IID_IWebBrowser),
|
|
|
|
ADD_KNOWN_GUID(IID_IWebBrowserApp),
|
|
|
|
ADD_KNOWN_GUID(IID_IWebBrowser2),
|
|
|
|
ADD_KNOWN_GUID(IID_IWebBrowser),
|
|
|
|
ADD_KNOWN_GUID(DIID_DWebBrowserEvents2),
|
|
|
|
ADD_KNOWN_GUID(DIID_DWebBrowserEvents),
|
2002-07-03 22:05:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// don't clobber preprocessor name space
|
|
|
|
#undef ADD_KNOWN_IID
|
2002-07-11 17:43:34 +00:00
|
|
|
#undef ADD_KNOWN_GUID
|
2002-07-03 22:05:30 +00:00
|
|
|
|
|
|
|
// try to find the interface in the table
|
2003-03-25 06:35:27 +00:00
|
|
|
for ( size_t ui = 0; ui < WXSIZEOF(aKnownIids); ui++ )
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
2003-03-25 06:35:27 +00:00
|
|
|
if ( riid == *aKnownIids[ui].pIid )
|
2002-07-03 22:05:30 +00:00
|
|
|
{
|
|
|
|
return aKnownIids[ui].szName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// unknown IID, just transform to string
|
|
|
|
LPOLESTR str = NULL;
|
|
|
|
StringFromIID(riid, &str);
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
wxString s = str;
|
|
|
|
CoTaskMemFree(str);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
else
|
2003-03-25 06:35:27 +00:00
|
|
|
return wxT("StringFromIID() error");
|
2002-07-03 22:05:30 +00:00
|
|
|
}
|