2 #include <wx/strconv.h>
13 // Depending on compilation mode, the wx headers may have undef'd
14 // this, but in this case we need it so the virtual method in
15 // FrameSite will match what is in oleidl.h.
18 #define GetObject GetObjectW
20 #define GetObject GetObjectA
25 //////////////////////////////////////////////////////////////////////
26 BEGIN_EVENT_TABLE(wxActiveX
, wxWindow
)
28 EVT_SET_FOCUS(OnSetFocus
)
29 EVT_KILL_FOCUS(OnKillFocus
)
35 public IOleClientSite
,
36 public IOleInPlaceSiteEx
,
37 public IOleInPlaceFrame
,
38 public IOleItemContainer
,
40 public IOleCommandTarget
,
41 public IOleDocumentSite
,
43 public IOleControlSite
46 DECLARE_OLE_UNKNOWN(FrameSite
);
49 FrameSite(wxActiveX
* win
);
53 STDMETHODIMP
GetWindow(HWND
*);
54 STDMETHODIMP
ContextSensitiveHelp(BOOL
);
57 STDMETHODIMP
GetBorder(LPRECT
);
58 STDMETHODIMP
RequestBorderSpace(LPCBORDERWIDTHS
);
59 STDMETHODIMP
SetBorderSpace(LPCBORDERWIDTHS
);
60 STDMETHODIMP
SetActiveObject(IOleInPlaceActiveObject
*, LPCOLESTR
);
63 STDMETHODIMP
InsertMenus(HMENU
, LPOLEMENUGROUPWIDTHS
);
64 STDMETHODIMP
SetMenu(HMENU
, HOLEMENU
, HWND
);
65 STDMETHODIMP
RemoveMenus(HMENU
);
66 STDMETHODIMP
SetStatusText(LPCOLESTR
);
67 STDMETHODIMP
EnableModeless(BOOL
);
68 STDMETHODIMP
TranslateAccelerator(LPMSG
, WORD
);
71 STDMETHODIMP
CanInPlaceActivate();
72 STDMETHODIMP
OnInPlaceActivate();
73 STDMETHODIMP
OnUIActivate();
74 STDMETHODIMP
GetWindowContext(IOleInPlaceFrame
**, IOleInPlaceUIWindow
**,
75 LPRECT
, LPRECT
, LPOLEINPLACEFRAMEINFO
);
76 STDMETHODIMP
Scroll(SIZE
);
77 STDMETHODIMP
OnUIDeactivate(BOOL
);
78 STDMETHODIMP
OnInPlaceDeactivate();
79 STDMETHODIMP
DiscardUndoState();
80 STDMETHODIMP
DeactivateAndUndo();
81 STDMETHODIMP
OnPosRectChange(LPCRECT
);
84 STDMETHODIMP
OnInPlaceActivateEx(BOOL
*, DWORD
);
85 STDMETHODIMP
OnInPlaceDeactivateEx(BOOL
);
86 STDMETHODIMP
RequestUIActivate();
89 STDMETHODIMP
SaveObject();
90 STDMETHODIMP
GetMoniker(DWORD
, DWORD
, IMoniker
**);
91 STDMETHODIMP
GetContainer(LPOLECONTAINER FAR
*);
92 STDMETHODIMP
ShowObject();
93 STDMETHODIMP
OnShowWindow(BOOL
);
94 STDMETHODIMP
RequestNewObjectLayout();
97 STDMETHODIMP
OnControlInfoChanged();
98 STDMETHODIMP
LockInPlaceActive(BOOL
);
99 STDMETHODIMP
GetExtendedControl(IDispatch
**);
100 STDMETHODIMP
TransformCoords(POINTL
*, POINTF
*, DWORD
);
101 STDMETHODIMP
TranslateAccelerator(LPMSG
, DWORD
);
102 STDMETHODIMP
OnFocus(BOOL
);
103 STDMETHODIMP
ShowPropertyFrame();
106 STDMETHODIMP
QueryStatus(const GUID
*, ULONG
, OLECMD
[], OLECMDTEXT
*);
107 STDMETHODIMP
Exec(const GUID
*, DWORD
, DWORD
, VARIANTARG
*, VARIANTARG
*);
110 STDMETHODIMP
ParseDisplayName(IBindCtx
*, LPOLESTR
, ULONG
*, IMoniker
**);
113 STDMETHODIMP
EnumObjects(DWORD
, IEnumUnknown
**);
114 STDMETHODIMP
LockContainer(BOOL
);
117 STDMETHODIMP
GetObject(LPOLESTR
, DWORD
, IBindCtx
*, REFIID
, void**);
118 STDMETHODIMP
GetObjectStorage(LPOLESTR
, IBindCtx
*, REFIID
, void**);
119 STDMETHODIMP
IsRunning(LPOLESTR
);
122 STDMETHODIMP
GetIDsOfNames(REFIID
, OLECHAR
**, unsigned int, LCID
, DISPID
*);
123 STDMETHODIMP
GetTypeInfo(unsigned int, LCID
, ITypeInfo
**);
124 STDMETHODIMP
GetTypeInfoCount(unsigned int*);
125 STDMETHODIMP
Invoke(DISPID
, REFIID
, LCID
, WORD
, DISPPARAMS
*, VARIANT
*, EXCEPINFO
*, UINT
*);
128 void STDMETHODCALLTYPE
OnDataChange(FORMATETC
*, STGMEDIUM
*);
129 void STDMETHODCALLTYPE
OnViewChange(DWORD
, LONG
);
130 void STDMETHODCALLTYPE
OnRename(IMoniker
*);
131 void STDMETHODCALLTYPE
OnSave();
132 void STDMETHODCALLTYPE
OnClose();
135 HRESULT STDMETHODCALLTYPE
ActivateMe(IOleDocumentView __RPC_FAR
*pViewToActivate
);
139 wxActiveX
* m_window
;
144 bool m_bSupportsWindowlessActivation
;
145 bool m_bInPlaceLocked
;
146 bool m_bInPlaceActive
;
152 LCID m_nAmbientLocale
;
153 COLORREF m_clrAmbientForeColor
;
154 COLORREF m_clrAmbientBackColor
;
155 bool m_bAmbientShowHatching
;
156 bool m_bAmbientShowGrabHandles
;
157 bool m_bAmbientAppearance
;
160 DEFINE_OLE_TABLE(FrameSite
)
161 OLE_INTERFACE(IID_IUnknown
, IOleClientSite
)
163 OLE_IINTERFACE(IOleClientSite
)
165 OLE_INTERFACE(IID_IOleWindow
, IOleInPlaceSite
)
166 OLE_IINTERFACE(IOleInPlaceSite
)
167 OLE_IINTERFACE(IOleInPlaceSiteEx
)
169 //OLE_IINTERFACE(IOleWindow)
170 OLE_IINTERFACE(IOleInPlaceUIWindow
)
171 OLE_IINTERFACE(IOleInPlaceFrame
)
173 OLE_IINTERFACE(IParseDisplayName
)
174 OLE_IINTERFACE(IOleContainer
)
175 OLE_IINTERFACE(IOleItemContainer
)
177 OLE_IINTERFACE(IDispatch
)
179 OLE_IINTERFACE(IOleCommandTarget
)
181 OLE_IINTERFACE(IOleDocumentSite
)
183 OLE_IINTERFACE(IAdviseSink
)
185 OLE_IINTERFACE(IOleControlSite
)
189 wxActiveX::wxActiveX(wxWindow
* parent
, REFCLSID clsid
, wxWindowID id
,
193 const wxString
& name
) :
194 wxWindow(parent
, id
, pos
, size
, style
, name
)
196 m_bAmbientUserMode
= true;
197 m_docAdviseCookie
= 0;
198 CreateActiveX(clsid
);
201 wxActiveX::wxActiveX(wxWindow
* parent
, wxString progId
, wxWindowID id
,
205 const wxString
& name
) :
206 wxWindow(parent
, id
, pos
, size
, style
, name
)
208 m_bAmbientUserMode
= true;
209 m_docAdviseCookie
= 0;
210 CreateActiveX((LPOLESTR
) (const wchar_t *) progId
.wc_str(wxConvUTF8
));
213 wxActiveX::~wxActiveX()
215 // disconnect connection points
216 wxOleConnectionArray::iterator it
= m_connections
.begin();
217 while (it
!= m_connections
.end())
219 wxOleConnectionPoint
& cp
= it
->first
;
220 cp
->Unadvise(it
->second
);
224 m_connections
.clear();
226 if (m_oleInPlaceObject
.Ok())
228 m_oleInPlaceObject
->InPlaceDeactivate();
229 m_oleInPlaceObject
->UIDeactivate();
233 if (m_oleObject
.Ok())
235 if (m_docAdviseCookie
!= 0)
236 m_oleObject
->Unadvise(m_docAdviseCookie
);
238 m_oleObject
->DoVerb(OLEIVERB_HIDE
, NULL
, m_clientSite
, 0, (HWND
) GetHWND(), NULL
);
239 m_oleObject
->Close(OLECLOSE_NOSAVE
);
240 m_oleObject
->SetClientSite(NULL
);
244 void wxActiveX::CreateActiveX(REFCLSID clsid
)
250 ////////////////////////////////////////////////////////
252 FrameSite
*frame
= new FrameSite(this);
254 hret
= m_clientSite
.QueryInterface(IID_IOleClientSite
, (IDispatch
*) frame
);
255 wxASSERT(SUCCEEDED(hret
));
257 wxAutoOleInterface
<IAdviseSink
> adviseSink(IID_IAdviseSink
, (IDispatch
*) frame
);
258 wxASSERT(adviseSink
.Ok());
261 // // Create Object, get IUnknown interface
262 m_ActiveX
.CreateInstance(clsid
, IID_IUnknown
);
263 wxASSERT(m_ActiveX
.Ok());
268 // Get IOleObject interface
269 hret
= m_oleObject
.QueryInterface(IID_IOleObject
, m_ActiveX
);
270 wxASSERT(SUCCEEDED(hret
));
273 m_docAdviseCookie
= 0;
274 hret
= m_oleObject
->Advise(adviseSink
, &m_docAdviseCookie
);
275 WXOLE_WARN(hret
, "m_oleObject->Advise(adviseSink, &m_docAdviseCookie),\"Advise\")");
276 m_oleObject
->SetHostNames(L
"wxActiveXContainer", NULL
);
277 OleSetContainedObject(m_oleObject
, TRUE
);
281 // Get IOleInPlaceObject interface
282 hret
= m_oleInPlaceObject
.QueryInterface(IID_IOleInPlaceObject
, m_ActiveX
);
283 wxASSERT(SUCCEEDED(hret
));
287 m_oleObject
->GetMiscStatus(DVASPECT_CONTENT
, &dwMiscStatus
);
288 wxASSERT(SUCCEEDED(hret
));
290 // set client site first ?
291 if (dwMiscStatus
& OLEMISC_SETCLIENTSITEFIRST
)
292 m_oleObject
->SetClientSite(m_clientSite
);
296 wxAutoOleInterface
<IPersistStreamInit
>
297 pPersistStreamInit(IID_IPersistStreamInit
, m_oleObject
);
299 if (pPersistStreamInit
.Ok())
301 hret
= pPersistStreamInit
->InitNew();
302 WXOLE_WARN(hret
, "CreateActiveX::pPersistStreamInit->InitNew()");
305 if (! (dwMiscStatus
& OLEMISC_SETCLIENTSITEFIRST
))
306 m_oleObject
->SetClientSite(m_clientSite
);
310 GetClientSize(&w
, &h
);
319 if (m_oleInPlaceObject
.Ok())
321 hret
= m_oleInPlaceObject
->GetWindow(&m_oleObjectHWND
);
322 WXOLE_WARN(hret
, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
324 ::SetActiveWindow(m_oleObjectHWND
);
328 if (! (dwMiscStatus
& OLEMISC_INVISIBLEATRUNTIME
))
330 if (w
> 0 && h
> 0 && m_oleInPlaceObject
.Ok())
331 m_oleInPlaceObject
->SetObjectRects(&posRect
, &posRect
);
333 hret
= m_oleObject
->DoVerb(OLEIVERB_INPLACEACTIVATE
, NULL
, m_clientSite
, 0, (HWND
)GetHWND(), &posRect
);
334 hret
= m_oleObject
->DoVerb(OLEIVERB_SHOW
, 0, m_clientSite
, 0, (HWND
)GetHWND(), &posRect
);
337 if (! m_oleObjectHWND
&& m_oleInPlaceObject
.Ok())
339 hret
= m_oleInPlaceObject
->GetWindow(&m_oleObjectHWND
);
340 WXOLE_WARN(hret
, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
345 ::SetActiveWindow(m_oleObjectHWND
);
346 ::ShowWindow(m_oleObjectHWND
, SW_SHOW
);
350 void wxActiveX::CreateActiveX(LPOLESTR progId
)
353 if (CLSIDFromProgID(progId
, &clsid
) != S_OK
)
356 CreateActiveX(clsid
);
359 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
360 // Case Insensitive Map of Event names to eventTypes
361 // created dynamically at run time in:
362 // EVT_ACTIVEX(eventName, id, fn)
363 // we map the pointer to them so that:
364 // const wxEventType& RegisterActiveXEvent(wxString eventName);
365 // can return a const reference, which is neccessary for event tables
366 // probably should use a wxWindows hash table here, but I'm lazy ...
367 struct less_wxStringI
369 bool operator()(const wxString
& x
, const wxString
& y
) const
371 return x
.CmpNoCase(y
) < 0;
375 typedef map
<wxString
, wxEventType
*, less_wxStringI
> ActiveXEventMap
;
376 static ActiveXEventMap sg_eventMap
;
378 // one off class for automatic freeing of activeX eventtypes
379 class ActiveXEventMapFlusher
382 ~ActiveXEventMapFlusher()
384 ActiveXEventMap::iterator it
= sg_eventMap
.end();
385 while (it
!= sg_eventMap
.end())
393 static ActiveXEventMapFlusher s_dummyActiveXEventMapFlusher
;
395 const wxEventType
& RegisterActiveXEvent(wxChar
*eventName
)
397 wxString ev
= eventName
;
398 ActiveXEventMap::iterator it
= sg_eventMap
.find(ev
);
399 if (it
== sg_eventMap
.end())
401 wxEventType
*et
= new wxEventType(wxNewEventType());
402 sg_eventMap
[ev
] = et
;
407 return *(it
->second
);
410 //////////////////////////////////////////////////////
411 bool MSWVariantToVariant(VARIANTARG
& va
, wxVariant
& vx
)
415 case VT_VARIANT
| VT_BYREF
:
416 return MSWVariantToVariant(*va
.pvarVal
, vx
);
423 case VT_I2
| VT_BYREF
:
424 case VT_I4
| VT_BYREF
:
425 vx
= (long) *va
.piVal
;
429 vx
= wxString(va
.bstrVal
);
432 case VT_BSTR
| VT_BYREF
:
433 vx
= wxString(*va
.pbstrVal
);
437 vx
= (va
.boolVal
!= FALSE
);
440 case VT_BOOL
| VT_BYREF
:
441 vx
= (*va
.pboolVal
!= FALSE
);
450 bool VariantToMSWVariant(wxVariant
& vx
, VARIANTARG
& va
)
454 case VT_VARIANT
| VT_BYREF
:
455 return VariantToMSWVariant(vx
, va
);
462 case VT_I2
| VT_BYREF
:
463 case VT_I4
| VT_BYREF
:
464 *va
.piVal
= (long) vx
;
468 va
.boolVal
= ((bool) vx
) ? TRUE
: FALSE
;
471 case VT_BOOL
| VT_BYREF
:
472 *va
.pboolVal
= ((bool) vx
) ? TRUE
: FALSE
;
480 class wxActiveXEvents
: public IDispatch
483 DECLARE_OLE_UNKNOWN(wxActiveXEvents
);
486 wxActiveX
*m_activeX
;
489 wxActiveXEvents(wxActiveX
*ax
) : m_activeX(ax
) {}
495 STDMETHODIMP
GetIDsOfNames(REFIID r
, OLECHAR
** o
, unsigned int i
, LCID l
, DISPID
* d
)
500 STDMETHODIMP
GetTypeInfo(unsigned int i
, LCID l
, ITypeInfo
** t
)
505 STDMETHODIMP
GetTypeInfoCount(unsigned int* i
)
512 STDMETHODIMP
Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
513 WORD wFlags
, DISPPARAMS
* pDispParams
,
514 VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
,
515 unsigned int * puArgErr
)
517 if (wFlags
& (DISPATCH_PROPERTYGET
| DISPATCH_PROPERTYPUT
| DISPATCH_PROPERTYPUTREF
))
520 // map dispid to name
521 wxActiveX::MemberIdList::iterator mid
= m_activeX
->m_eventsIdx
.find((MEMBERID
) dispIdMember
);
522 if (mid
== m_activeX
->m_eventsIdx
.end())
525 int idx
= mid
->second
;
528 wxActiveX::FuncX
&func
= m_activeX
->m_events
[idx
];
530 ActiveXEventMap::iterator it
= sg_eventMap
.find(func
.name
);
531 if (it
== sg_eventMap
.end())
534 wxActiveXEvent event
;
535 event
.SetId(m_activeX
->GetId());
536 event
.SetEventType(*(it
->second
));
537 event
.m_params
.NullList();
543 for (int i
= pDispParams
->cArgs
- 1; i
>= 0; i
--)
545 VARIANTARG
& va
= pDispParams
->rgvarg
[i
];
546 wxActiveX::ParamX
&px
= func
.params
[pDispParams
->cArgs
- i
- 1];
549 MSWVariantToVariant(va
, vx
);
551 event
.m_params
.Append(vx
);
557 m_activeX
->GetParent()->ProcessEvent(event
);
558 for (unsigned int i
= 0; i
< pDispParams
->cArgs
; i
++)
560 VARIANTARG
& va
= pDispParams
->rgvarg
[i
];
561 wxActiveX::ParamX
&px
= func
.params
[pDispParams
->cArgs
- i
- 1];
565 wxVariant
& vx
= event
.m_params
[pDispParams
->cArgs
- i
- 1];
567 VariantToMSWVariant(vx
, va
);
572 m_activeX
->GetParent()->AddPendingEvent(event
);
579 DEFINE_OLE_TABLE(wxActiveXEvents
)
580 OLE_IINTERFACE(IUnknown
)
581 OLE_INTERFACE(IID_IDispatch
, IDispatch
)
585 int wxActiveXEvent::ParamCount() const
587 return m_params
.GetCount();
590 static wxVariant nullVar
;
592 wxVariant
wxActiveXEvent::operator[] (int idx
) const
594 return (wxVariant
&) operator[] (idx
);
597 wxVariant
& wxActiveXEvent::operator[] (int idx
)
599 wxASSERT(idx
>= 0 && idx
< ParamCount());
601 return m_params
[idx
];
604 wxVariant
wxActiveXEvent::operator[] (wxString name
) const
606 return (wxVariant
&) operator[] (name
);
609 wxVariant
& wxActiveXEvent::operator[] (wxString name
)
611 for (int i
= 0; i
< m_params
.GetCount(); i
++)
613 if (name
.CmpNoCase(m_params
[i
].GetName()) == 0)
617 wxString err
= "wxActiveXEvent::operator[] invalid name <" + name
+ ">";
618 err
+= "\r\nValid Names = :\r\n";
619 for (i
= 0; i
< m_params
.GetCount(); i
++)
621 err
+= m_params
[i
].GetName();
625 wxASSERT_MSG(false, err
);
630 void wxActiveX::GetTypeInfo()
633 We are currently only interested in the IDispatch interface
634 to the control. For dual interfaces (TypeKind = TKIND_INTERFACE)
635 we should drill down through the inheritance
636 (using TYPEATTR->cImplTypes) and GetRefTypeOfImplType(n)
637 and retrieve all the func names etc that way, then generate a C++
640 But we don't do this and probably never will, so if we have a DUAL
641 interface then we query for the IDispatch
642 via GetRefTypeOfImplType(-1).
647 // get type info via class info
648 wxAutoOleInterface
<IProvideClassInfo
> classInfo(IID_IProvideClassInfo
, m_ActiveX
);
649 if (! classInfo
.Ok())
653 wxAutoOleInterface
<ITypeInfo
> typeInfo
;
654 hret
= classInfo
->GetClassInfo(typeInfo
.GetRef());
660 hret
= typeInfo
->GetTypeAttr(&ta
);
664 // this should be a TKIND_COCLASS
665 wxASSERT(ta
->typekind
== TKIND_COCLASS
);
667 // iterate contained interfaces
668 for (int i
= 0; i
< ta
->cImplTypes
; i
++)
672 // get dispatch type info handle
673 hret
= typeInfo
->GetRefTypeOfImplType(i
, &rt
);
674 if (! SUCCEEDED(hret
))
677 // get dispatch type info interface
678 wxAutoOleInterface
<ITypeInfo
> ti
;
679 hret
= typeInfo
->GetRefTypeInfo(rt
, ti
.GetRef());
683 // check if default event sink
684 bool defEventSink
= false;
685 int impTypeFlags
= 0;
686 typeInfo
->GetImplTypeFlags(i
, &impTypeFlags
);
688 if (impTypeFlags
& IMPLTYPEFLAG_FDEFAULT
)
690 if (impTypeFlags
& IMPLTYPEFLAG_FSOURCE
)
692 WXOLE_TRACEOUT("Default Event Sink");
697 WXOLE_TRACEOUT("Default Interface");
703 GetTypeInfo(ti
, defEventSink
);
708 typeInfo
->ReleaseTypeAttr(ta
);
711 void wxActiveX::GetTypeInfo(ITypeInfo
*ti
, bool defEventSink
)
714 wxAutoOleInterface
<ITypeInfo
> typeInfo(ti
);
718 HRESULT hret
= typeInfo
->GetTypeAttr(&ta
);
722 if (ta
->typekind
== TKIND_DISPATCH
)
724 WXOLE_TRACEOUT("GUID = " << GetIIDName(ta
->guid
).c_str());
728 wxActiveXEvents
*disp
= new wxActiveXEvents(this);
729 ConnectAdvise(ta
->guid
, disp
);
733 // Get Function Names
734 for (int i
= 0; i
< ta
->cFuncs
; i
++)
736 FUNCDESC FAR
*fd
= NULL
;
738 hret
= typeInfo
->GetFuncDesc(i
, &fd
);
742 BSTR anames
[1] = {NULL
};
745 hret
= typeInfo
->GetNames(fd
->memid
, anames
, 1, &n
);
749 wxString name
= anames
[0];
751 WXOLE_TRACEOUT("Name " << i
<< " = " << name
.c_str());
752 SysFreeString(anames
[0]);
758 func
.memid
= fd
->memid
;
762 unsigned int maxPNames
= fd
->cParams
+ 1;
763 unsigned int nPNames
= 0;
764 BSTR
*pnames
= new BSTR
[maxPNames
];
766 hret
= typeInfo
->GetNames(fd
->memid
, pnames
, maxPNames
, &nPNames
);
768 SysFreeString(pnames
[0]);
770 for (int p
= 0; p
< fd
->cParams
; p
++)
773 param
.flags
= fd
->lprgelemdescParam
[p
].idldesc
.wIDLFlags
;
774 param
.vt
= fd
->lprgelemdescParam
[p
].tdesc
.vt
;
775 param
.name
= pnames
[p
+ 1];
776 SysFreeString(pnames
[p
+ 1]);
778 func
.hasOut
|= param
.IsOut();
779 func
.params
.push_back(param
);
783 m_events
.push_back(func
);
784 m_eventsIdx
[fd
->memid
] = m_events
.size() - 1;
788 typeInfo
->ReleaseFuncDesc(fd
);
792 typeInfo
->ReleaseTypeAttr(ta
);
795 HRESULT
wxActiveX::ConnectAdvise(REFIID riid
, IUnknown
*events
)
797 wxOleConnectionPoint cp
;
798 DWORD adviseCookie
= 0;
800 wxAutoOleInterface
<IConnectionPointContainer
> cpContainer(IID_IConnectionPointContainer
, m_ActiveX
);
801 if (! cpContainer
.Ok())
804 HRESULT hret
= cpContainer
->FindConnectionPoint(riid
, cp
.GetRef());
805 if (! SUCCEEDED(hret
))
808 hret
= cp
->Advise(events
, &adviseCookie
);
811 m_connections
.push_back(wxOleConnection(cp
, adviseCookie
));
816 HRESULT
wxActiveX::AmbientPropertyChanged(DISPID dispid
)
818 wxAutoOleInterface
<IOleControl
> oleControl(IID_IOleControl
, m_oleObject
);
821 return oleControl
->OnAmbientPropertyChange(dispid
);
826 #define HIMETRIC_PER_INCH 2540
827 #define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
829 static void PixelsToHimetric(SIZEL
&sz
)
837 HDC dc
= GetDC(NULL
);
838 logX
= GetDeviceCaps(dc
, LOGPIXELSX
);
839 logY
= GetDeviceCaps(dc
, LOGPIXELSY
);
843 #define HIMETRIC_INCH 2540
844 #define CONVERT(x, logpixels) MulDiv(HIMETRIC_INCH, (x), (logpixels))
846 sz
.cx
= CONVERT(sz
.cx
, logX
);
847 sz
.cy
= CONVERT(sz
.cy
, logY
);
854 void wxActiveX::OnSize(wxSizeEvent
& event
)
857 GetClientSize(&w
, &h
);
865 if (w
<= 0 && h
<= 0)
868 if (m_oleInPlaceObject
.Ok())
869 m_oleInPlaceObject
->SetObjectRects(&posRect
, &posRect
);
871 // extents are in HIMETRIC units
872 if (m_oleObject
.Ok())
875 PixelsToHimetric(sz
);
879 m_oleObject
->GetExtent(DVASPECT_CONTENT
, &sz2
);
880 if (sz2
.cx
!= sz
.cx
|| sz
.cy
!= sz2
.cy
)
881 m_oleObject
->SetExtent(DVASPECT_CONTENT
, &sz
);
885 void wxActiveX::OnSetFocus(wxFocusEvent
& event
)
887 if (m_oleInPlaceActiveObject
.Ok())
888 m_oleInPlaceActiveObject
->OnFrameWindowActivate(TRUE
);
891 void wxActiveX::OnKillFocus(wxFocusEvent
& event
)
893 if (m_oleInPlaceActiveObject
.Ok())
894 m_oleInPlaceActiveObject
->OnFrameWindowActivate(FALSE
);
898 FrameSite::FrameSite(wxActiveX
* win
)
901 m_bSupportsWindowlessActivation
= true;
902 m_bInPlaceLocked
= false;
904 m_bInPlaceActive
= false;
905 m_bWindowless
= false;
907 m_nAmbientLocale
= 0;
908 m_clrAmbientForeColor
= ::GetSysColor(COLOR_WINDOWTEXT
);
909 m_clrAmbientBackColor
= ::GetSysColor(COLOR_WINDOW
);
910 m_bAmbientShowHatching
= true;
911 m_bAmbientShowGrabHandles
= true;
912 m_bAmbientAppearance
= true;
915 m_hWndParent
= (HWND
)m_window
->GetHWND();
918 FrameSite::~FrameSite()
925 HRESULT
FrameSite::GetIDsOfNames(REFIID riid
, OLECHAR
** rgszNames
, unsigned int cNames
,
926 LCID lcid
, DISPID
* rgDispId
)
928 WXOLE_TRACE("IDispatch::GetIDsOfNames");
932 HRESULT
FrameSite::GetTypeInfo(unsigned int iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
934 WXOLE_TRACE("IDispatch::GetTypeInfo");
938 HRESULT
FrameSite::GetTypeInfoCount(unsigned int * pcTInfo
)
940 WXOLE_TRACE("IDispatch::GetTypeInfoCount");
944 HRESULT
FrameSite::Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
945 WORD wFlags
, DISPPARAMS
* pDispParams
,
946 VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
,
947 unsigned int * puArgErr
)
949 WXOLE_TRACE("IDispatch::Invoke");
951 if (!(wFlags
& DISPATCH_PROPERTYGET
))
956 if (pVarResult
== NULL
)
959 //The most common case is boolean, use as an initial type
960 V_VT(pVarResult
) = VT_BOOL
;
962 switch (dispIdMember
)
964 case DISPID_AMBIENT_MESSAGEREFLECT
:
965 WXOLE_TRACE("Invoke::DISPID_AMBIENT_MESSAGEREFLECT");
966 V_BOOL(pVarResult
)= FALSE
;
969 case DISPID_AMBIENT_DISPLAYASDEFAULT
:
970 WXOLE_TRACE("Invoke::DISPID_AMBIENT_DISPLAYASDEFAULT");
971 V_BOOL(pVarResult
)= TRUE
;
974 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
975 WXOLE_TRACE("Invoke::DISPID_AMBIENT_OFFLINEIFNOTCONNECTED");
976 V_BOOL(pVarResult
) = TRUE
;
980 case DISPID_AMBIENT_SILENT
:
981 WXOLE_TRACE("Invoke::DISPID_AMBIENT_SILENT");
982 V_BOOL(pVarResult
)= TRUE
;
985 case DISPID_AMBIENT_APPEARANCE
:
986 pVarResult
->vt
= VT_BOOL
;
987 pVarResult
->boolVal
= m_bAmbientAppearance
;
990 case DISPID_AMBIENT_FORECOLOR
:
991 pVarResult
->vt
= VT_I4
;
992 pVarResult
->lVal
= (long) m_clrAmbientForeColor
;
995 case DISPID_AMBIENT_BACKCOLOR
:
996 pVarResult
->vt
= VT_I4
;
997 pVarResult
->lVal
= (long) m_clrAmbientBackColor
;
1000 case DISPID_AMBIENT_LOCALEID
:
1001 pVarResult
->vt
= VT_I4
;
1002 pVarResult
->lVal
= (long) m_nAmbientLocale
;
1005 case DISPID_AMBIENT_USERMODE
:
1006 pVarResult
->vt
= VT_BOOL
;
1007 pVarResult
->boolVal
= m_window
->m_bAmbientUserMode
;
1010 case DISPID_AMBIENT_SHOWGRABHANDLES
:
1011 pVarResult
->vt
= VT_BOOL
;
1012 pVarResult
->boolVal
= m_bAmbientShowGrabHandles
;
1015 case DISPID_AMBIENT_SHOWHATCHING
:
1016 pVarResult
->vt
= VT_BOOL
;
1017 pVarResult
->boolVal
= m_bAmbientShowHatching
;
1021 return DISP_E_MEMBERNOTFOUND
;
1029 HRESULT
FrameSite::GetWindow(HWND
* phwnd
)
1031 WXOLE_TRACE("IOleWindow::GetWindow");
1033 return E_INVALIDARG
;
1034 (*phwnd
) = m_hWndParent
;
1038 HRESULT
FrameSite::ContextSensitiveHelp(BOOL fEnterMode
)
1040 WXOLE_TRACE("IOleWindow::ContextSensitiveHelp");
1044 //IOleInPlaceUIWindow
1046 HRESULT
FrameSite::GetBorder(LPRECT lprectBorder
)
1048 WXOLE_TRACE("IOleInPlaceUIWindow::GetBorder");
1049 if (lprectBorder
== NULL
)
1050 return E_INVALIDARG
;
1051 return INPLACE_E_NOTOOLSPACE
;
1054 HRESULT
FrameSite::RequestBorderSpace(LPCBORDERWIDTHS pborderwidths
)
1056 WXOLE_TRACE("IOleInPlaceUIWindow::RequestBorderSpace");
1057 if (pborderwidths
== NULL
)
1058 return E_INVALIDARG
;
1059 return INPLACE_E_NOTOOLSPACE
;
1062 HRESULT
FrameSite::SetBorderSpace(LPCBORDERWIDTHS pborderwidths
)
1064 WXOLE_TRACE("IOleInPlaceUIWindow::SetBorderSpace");
1068 HRESULT
FrameSite::SetActiveObject(IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
1070 WXOLE_TRACE("IOleInPlaceUIWindow::SetActiveObject");
1073 pActiveObject
->AddRef();
1075 m_window
->m_oleInPlaceActiveObject
= pActiveObject
;
1081 HRESULT
FrameSite::InsertMenus(HMENU hmenuShared
, LPOLEMENUGROUPWIDTHS lpMenuWidths
)
1083 WXOLE_TRACE("IOleInPlaceFrame::InsertMenus");
1087 HRESULT
FrameSite::SetMenu(HMENU hmenuShared
, HOLEMENU holemenu
, HWND hwndActiveObject
)
1089 WXOLE_TRACE("IOleInPlaceFrame::SetMenu");
1093 HRESULT
FrameSite::RemoveMenus(HMENU hmenuShared
)
1095 WXOLE_TRACE("IOleInPlaceFrame::RemoveMenus");
1099 HRESULT
FrameSite::SetStatusText(LPCOLESTR pszStatusText
)
1101 WXOLE_TRACE("IOleInPlaceFrame::SetStatusText");
1102 //((wxFrame*)wxGetApp().GetTopWindow())->GetStatusBar()->SetStatusText(pszStatusText);
1106 HRESULT
FrameSite::EnableModeless(BOOL fEnable
)
1108 WXOLE_TRACE("IOleInPlaceFrame::EnableModeless");
1112 HRESULT
FrameSite::TranslateAccelerator(LPMSG lpmsg
, WORD wID
)
1114 WXOLE_TRACE("IOleInPlaceFrame::TranslateAccelerator");
1115 // TODO: send an event with this id
1116 if (m_window
->m_oleInPlaceActiveObject
.Ok())
1117 m_window
->m_oleInPlaceActiveObject
->TranslateAccelerator(lpmsg
);
1124 HRESULT
FrameSite::CanInPlaceActivate()
1126 WXOLE_TRACE("IOleInPlaceSite::CanInPlaceActivate");
1130 HRESULT
FrameSite::OnInPlaceActivate()
1132 WXOLE_TRACE("IOleInPlaceSite::OnInPlaceActivate");
1133 m_bInPlaceActive
= true;
1137 HRESULT
FrameSite::OnUIActivate()
1139 WXOLE_TRACE("IOleInPlaceSite::OnUIActivate");
1144 HRESULT
FrameSite::GetWindowContext(IOleInPlaceFrame
**ppFrame
,
1145 IOleInPlaceUIWindow
**ppDoc
,
1147 LPRECT lprcClipRect
,
1148 LPOLEINPLACEFRAMEINFO lpFrameInfo
)
1150 WXOLE_TRACE("IOleInPlaceSite::GetWindowContext");
1151 if (ppFrame
== NULL
|| ppDoc
== NULL
|| lprcPosRect
== NULL
||
1152 lprcClipRect
== NULL
|| lpFrameInfo
== NULL
)
1154 if (ppFrame
!= NULL
)
1158 return E_INVALIDARG
;
1161 HRESULT hr
= QueryInterface(IID_IOleInPlaceFrame
, (void **) ppFrame
);
1162 if (! SUCCEEDED(hr
))
1164 WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceFrame Error !");
1165 return E_UNEXPECTED
;
1168 hr
= QueryInterface(IID_IOleInPlaceUIWindow
, (void **) ppDoc
);
1169 if (! SUCCEEDED(hr
))
1171 WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceUIWindow Error !");
1172 (*ppFrame
)->Release();
1174 return E_UNEXPECTED
;
1178 m_window
->GetClientSize(&w
, &h
);
1181 lprcPosRect
->left
= lprcPosRect
->top
= 0;
1182 lprcPosRect
->right
= w
;
1183 lprcPosRect
->bottom
= h
;
1187 lprcClipRect
->left
= lprcClipRect
->top
= 0;
1188 lprcClipRect
->right
= w
;
1189 lprcClipRect
->bottom
= h
;
1192 memset(lpFrameInfo
, 0, sizeof(OLEINPLACEFRAMEINFO
));
1193 lpFrameInfo
->cb
= sizeof(OLEINPLACEFRAMEINFO
);
1194 lpFrameInfo
->hwndFrame
= m_hWndParent
;
1199 HRESULT
FrameSite::Scroll(SIZE scrollExtent
)
1201 WXOLE_TRACE("IOleInPlaceSite::Scroll");
1205 HRESULT
FrameSite::OnUIDeactivate(BOOL fUndoable
)
1207 WXOLE_TRACE("IOleInPlaceSite::OnUIDeactivate");
1208 m_bUIActive
= false;
1212 HRESULT
FrameSite::OnInPlaceDeactivate()
1214 WXOLE_TRACE("IOleInPlaceSite::OnInPlaceDeactivate");
1215 m_bInPlaceActive
= false;
1219 HRESULT
FrameSite::DiscardUndoState()
1221 WXOLE_TRACE("IOleInPlaceSite::DiscardUndoState");
1225 HRESULT
FrameSite::DeactivateAndUndo()
1227 WXOLE_TRACE("IOleInPlaceSite::DeactivateAndUndo");
1231 HRESULT
FrameSite::OnPosRectChange(LPCRECT lprcPosRect
)
1233 WXOLE_TRACE("IOleInPlaceSite::OnPosRectChange");
1234 if (m_window
->m_oleInPlaceObject
.Ok() && lprcPosRect
)
1235 m_window
->m_oleInPlaceObject
->SetObjectRects(lprcPosRect
, lprcPosRect
);
1242 HRESULT
FrameSite::OnInPlaceActivateEx(BOOL
* pfNoRedraw
, DWORD dwFlags
)
1244 WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceActivateEx");
1245 OleLockRunning(m_window
->m_ActiveX
, TRUE
, FALSE
);
1247 (*pfNoRedraw
) = FALSE
;
1251 HRESULT
FrameSite::OnInPlaceDeactivateEx(BOOL fNoRedraw
)
1253 WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceDeactivateEx");
1254 OleLockRunning(m_window
->m_ActiveX
, FALSE
, FALSE
);
1258 HRESULT
FrameSite::RequestUIActivate()
1260 WXOLE_TRACE("IOleInPlaceSiteEx::RequestUIActivate");
1267 HRESULT
FrameSite::SaveObject()
1269 WXOLE_TRACE("IOleClientSite::SaveObject");
1273 HRESULT
FrameSite::GetMoniker(DWORD dwAssign
, DWORD dwWhichMoniker
,
1276 WXOLE_TRACE("IOleClientSite::GetMoniker");
1280 HRESULT
FrameSite::GetContainer(LPOLECONTAINER
* ppContainer
)
1282 WXOLE_TRACE("IOleClientSite::GetContainer");
1283 if (ppContainer
== NULL
)
1284 return E_INVALIDARG
;
1286 HRESULT hr
= QueryInterface(IID_IOleContainer
, (void**)(ppContainer
));
1287 wxASSERT(SUCCEEDED(hr
));
1292 HRESULT
FrameSite::ShowObject()
1294 WXOLE_TRACE("IOleClientSite::ShowObject");
1295 if (m_window
->m_oleObjectHWND
)
1296 ::ShowWindow(m_window
->m_oleObjectHWND
, SW_SHOW
);
1300 HRESULT
FrameSite::OnShowWindow(BOOL fShow
)
1302 WXOLE_TRACE("IOleClientSite::OnShowWindow");
1306 HRESULT
FrameSite::RequestNewObjectLayout()
1308 WXOLE_TRACE("IOleClientSite::RequestNewObjectLayout");
1312 // IParseDisplayName
1314 HRESULT
FrameSite::ParseDisplayName(IBindCtx
*pbc
, LPOLESTR pszDisplayName
,
1315 ULONG
*pchEaten
, IMoniker
**ppmkOut
)
1317 WXOLE_TRACE("IParseDisplayName::ParseDisplayName");
1323 HRESULT
FrameSite::EnumObjects(DWORD grfFlags
, IEnumUnknown
**ppenum
)
1325 WXOLE_TRACE("IOleContainer::EnumObjects");
1329 HRESULT
FrameSite::LockContainer(BOOL fLock
)
1331 WXOLE_TRACE("IOleContainer::LockContainer");
1338 HRESULT
FrameSite::GetObject(LPOLESTR pszItem
, DWORD dwSpeedNeeded
,
1339 IBindCtx
* pbc
, REFIID riid
, void ** ppvObject
)
1341 WXOLE_TRACE("IOleItemContainer::GetObject");
1342 if (pszItem
== NULL
)
1343 return E_INVALIDARG
;
1344 if (ppvObject
== NULL
)
1345 return E_INVALIDARG
;
1348 return MK_E_NOOBJECT
;
1351 HRESULT
FrameSite::GetObjectStorage(LPOLESTR pszItem
, IBindCtx
* pbc
,
1352 REFIID riid
, void ** ppvStorage
)
1354 WXOLE_TRACE("IOleItemContainer::GetObjectStorage");
1355 if (pszItem
== NULL
)
1356 return E_INVALIDARG
;
1357 if (ppvStorage
== NULL
)
1358 return E_INVALIDARG
;
1361 return MK_E_NOOBJECT
;
1364 HRESULT
FrameSite::IsRunning(LPOLESTR pszItem
)
1366 WXOLE_TRACE("IOleItemContainer::IsRunning");
1367 if (pszItem
== NULL
)
1368 return E_INVALIDARG
;
1370 return MK_E_NOOBJECT
;
1377 HRESULT
FrameSite::OnControlInfoChanged()
1379 WXOLE_TRACE("IOleControlSite::OnControlInfoChanged");
1383 HRESULT
FrameSite::LockInPlaceActive(BOOL fLock
)
1385 WXOLE_TRACE("IOleControlSite::LockInPlaceActive");
1386 m_bInPlaceLocked
= (fLock
) ? true : false;
1390 HRESULT
FrameSite::GetExtendedControl(IDispatch
** ppDisp
)
1392 WXOLE_TRACE("IOleControlSite::GetExtendedControl");
1396 HRESULT
FrameSite::TransformCoords(POINTL
* pPtlHimetric
, POINTF
* pPtfContainer
, DWORD dwFlags
)
1398 WXOLE_TRACE("IOleControlSite::TransformCoords");
1401 if (pPtlHimetric
== NULL
)
1402 return E_INVALIDARG
;
1404 if (pPtfContainer
== NULL
)
1405 return E_INVALIDARG
;
1411 HRESULT
FrameSite::TranslateAccelerator(LPMSG pMsg
, DWORD grfModifiers
)
1413 WXOLE_TRACE("IOleControlSite::TranslateAccelerator");
1414 // TODO: send an event with this id
1418 HRESULT
FrameSite::OnFocus(BOOL fGotFocus
)
1420 WXOLE_TRACE("IOleControlSite::OnFocus");
1424 HRESULT
FrameSite::ShowPropertyFrame()
1426 WXOLE_TRACE("IOleControlSite::ShowPropertyFrame");
1432 HRESULT
FrameSite::QueryStatus(const GUID
* pguidCmdGroup
, ULONG cCmds
,
1433 OLECMD
* prgCmds
, OLECMDTEXT
* pCmdTet
)
1435 WXOLE_TRACE("IOleCommandTarget::QueryStatus");
1436 if (prgCmds
== NULL
) return E_INVALIDARG
;
1437 bool bCmdGroupFound
= false;
1439 for (ULONG nCmd
= 0; nCmd
< cCmds
; nCmd
++)
1441 // unsupported by default
1442 prgCmds
[nCmd
].cmdf
= 0;
1447 if (!bCmdGroupFound
) { OLECMDERR_E_UNKNOWNGROUP
; }
1451 HRESULT
FrameSite::Exec(const GUID
* pguidCmdGroup
, DWORD nCmdID
,
1452 DWORD nCmdExecOpt
, VARIANTARG
* pVaIn
,
1453 VARIANTARG
* pVaOut
)
1455 WXOLE_TRACE("IOleCommandTarget::Exec");
1456 bool bCmdGroupFound
= false;
1458 if (!bCmdGroupFound
) { OLECMDERR_E_UNKNOWNGROUP
; }
1459 return OLECMDERR_E_NOTSUPPORTED
;
1464 void STDMETHODCALLTYPE
FrameSite::OnDataChange(FORMATETC
* pFormatEtc
, STGMEDIUM
* pgStgMed
)
1466 WXOLE_TRACE("IAdviseSink::OnDataChange");
1469 void STDMETHODCALLTYPE
FrameSite::OnViewChange(DWORD dwAspect
, LONG lIndex
)
1471 WXOLE_TRACE("IAdviseSink::OnViewChange");
1472 // redraw the control
1475 void STDMETHODCALLTYPE
FrameSite::OnRename(IMoniker
* pmk
)
1477 WXOLE_TRACE("IAdviseSink::OnRename");
1480 void STDMETHODCALLTYPE
FrameSite::OnSave()
1482 WXOLE_TRACE("IAdviseSink::OnSave");
1485 void STDMETHODCALLTYPE
FrameSite::OnClose()
1487 WXOLE_TRACE("IAdviseSink::OnClose");
1490 /////////////////////////////////////////////
1492 HRESULT STDMETHODCALLTYPE
FrameSite::ActivateMe(
1493 /* [in] */ IOleDocumentView __RPC_FAR
*pViewToActivate
)
1495 wxAutoOleInterface
<IOleInPlaceSite
> inPlaceSite(IID_IOleInPlaceSite
, (IDispatch
*) this);
1496 if (!inPlaceSite
.Ok())
1499 if (pViewToActivate
)
1501 m_window
->m_docView
= pViewToActivate
;
1502 m_window
->m_docView
->SetInPlaceSite(inPlaceSite
);
1506 wxAutoOleInterface
<IOleDocument
> oleDoc(IID_IOleDocument
, m_window
->m_oleObject
);
1510 HRESULT hr
= oleDoc
->CreateView(inPlaceSite
, NULL
, 0, m_window
->m_docView
.GetRef());
1514 m_window
->m_docView
->SetInPlaceSite(inPlaceSite
);
1517 m_window
->m_docView
->UIActivate(TRUE
);
1524 static IMalloc
*iMalloc
= NULL
;
1526 IMalloc
*wxOleInit::GetIMalloc()
1532 wxOleInit::wxOleInit()
1534 if (OleInitialize(NULL
) == S_OK
&& iMalloc
== NULL
)
1535 CoGetMalloc(1, &iMalloc
);
1540 wxOleInit::~wxOleInit()
1544 if (iMalloc
->Release() == 0)
1551 wxString
OLEHResultToString(HRESULT hr
)
1558 case OLECMDERR_E_UNKNOWNGROUP
:
1559 return "The pguidCmdGroup parameter is not NULL but does not specify a recognized command group.";
1561 case OLECMDERR_E_NOTSUPPORTED
:
1562 return "The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup.";
1564 case OLECMDERR_E_DISABLED
:
1565 return "The command identified by nCmdID is currently disabled and cannot be executed.";
1567 case OLECMDERR_E_NOHELP
:
1568 return "The caller has asked for help on the command identified by nCmdID, but no help is available.";
1570 case OLECMDERR_E_CANCELED
:
1571 return "The user canceled the execution of the command.";
1574 return "E_INVALIDARG";
1577 return "E_OUTOFMEMORY";
1580 return "E_NOINTERFACE";
1583 return "E_UNEXPECTED";
1585 case STG_E_INVALIDFLAG
:
1586 return "STG_E_INVALIDFLAG";
1597 sprintf(buf
, "Unknown - 0x%X", hr
);
1598 return wxString(buf
);
1603 // borrowed from src/msw/ole/oleutils.cpp
1604 wxString
GetIIDName(REFIID riid
)
1606 // an association between symbolic name and numeric value of an IID
1610 const wxChar
*szName
;
1613 // construct the table containing all known interfaces
1614 #define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }
1615 #define ADD_KNOWN_GUID(name) { &name, _T(#name) }
1617 static const KNOWN_IID aKnownIids
[] =
1619 ADD_KNOWN_IID(AdviseSink
),
1620 ADD_KNOWN_IID(AdviseSink2
),
1621 ADD_KNOWN_IID(BindCtx
),
1622 ADD_KNOWN_IID(ClassFactory
),
1623 #if ( !defined( __VISUALC__) || (__VISUALC__!=1010) ) && !defined(__MWERKS__)
1624 ADD_KNOWN_IID(ContinueCallback
),
1625 ADD_KNOWN_IID(EnumOleDocumentViews
),
1626 ADD_KNOWN_IID(OleCommandTarget
),
1627 ADD_KNOWN_IID(OleDocument
),
1628 ADD_KNOWN_IID(OleDocumentSite
),
1629 ADD_KNOWN_IID(OleDocumentView
),
1630 ADD_KNOWN_IID(Print
),
1632 ADD_KNOWN_IID(DataAdviseHolder
),
1633 ADD_KNOWN_IID(DataObject
),
1634 ADD_KNOWN_IID(Debug
),
1635 ADD_KNOWN_IID(DebugStream
),
1636 ADD_KNOWN_IID(DfReserved1
),
1637 ADD_KNOWN_IID(DfReserved2
),
1638 ADD_KNOWN_IID(DfReserved3
),
1639 ADD_KNOWN_IID(Dispatch
),
1640 ADD_KNOWN_IID(DropSource
),
1641 ADD_KNOWN_IID(DropTarget
),
1642 ADD_KNOWN_IID(EnumCallback
),
1643 ADD_KNOWN_IID(EnumFORMATETC
),
1644 ADD_KNOWN_IID(EnumGeneric
),
1645 ADD_KNOWN_IID(EnumHolder
),
1646 ADD_KNOWN_IID(EnumMoniker
),
1647 ADD_KNOWN_IID(EnumOLEVERB
),
1648 ADD_KNOWN_IID(EnumSTATDATA
),
1649 ADD_KNOWN_IID(EnumSTATSTG
),
1650 ADD_KNOWN_IID(EnumString
),
1651 ADD_KNOWN_IID(EnumUnknown
),
1652 ADD_KNOWN_IID(EnumVARIANT
),
1653 ADD_KNOWN_IID(ExternalConnection
),
1654 ADD_KNOWN_IID(InternalMoniker
),
1655 ADD_KNOWN_IID(LockBytes
),
1656 ADD_KNOWN_IID(Malloc
),
1657 ADD_KNOWN_IID(Marshal
),
1658 ADD_KNOWN_IID(MessageFilter
),
1659 ADD_KNOWN_IID(Moniker
),
1660 ADD_KNOWN_IID(OleAdviseHolder
),
1661 ADD_KNOWN_IID(OleCache
),
1662 ADD_KNOWN_IID(OleCache2
),
1663 ADD_KNOWN_IID(OleCacheControl
),
1664 ADD_KNOWN_IID(OleClientSite
),
1665 ADD_KNOWN_IID(OleContainer
),
1666 ADD_KNOWN_IID(OleInPlaceActiveObject
),
1667 ADD_KNOWN_IID(OleInPlaceFrame
),
1668 ADD_KNOWN_IID(OleInPlaceObject
),
1669 ADD_KNOWN_IID(OleInPlaceSite
),
1670 ADD_KNOWN_IID(OleInPlaceUIWindow
),
1671 ADD_KNOWN_IID(OleItemContainer
),
1672 ADD_KNOWN_IID(OleLink
),
1673 ADD_KNOWN_IID(OleManager
),
1674 ADD_KNOWN_IID(OleObject
),
1675 ADD_KNOWN_IID(OlePresObj
),
1676 ADD_KNOWN_IID(OleWindow
),
1677 ADD_KNOWN_IID(PSFactory
),
1678 ADD_KNOWN_IID(ParseDisplayName
),
1679 ADD_KNOWN_IID(Persist
),
1680 ADD_KNOWN_IID(PersistFile
),
1681 ADD_KNOWN_IID(PersistStorage
),
1682 ADD_KNOWN_IID(PersistStream
),
1683 ADD_KNOWN_IID(ProxyManager
),
1684 ADD_KNOWN_IID(RootStorage
),
1685 ADD_KNOWN_IID(RpcChannel
),
1686 ADD_KNOWN_IID(RpcProxy
),
1687 ADD_KNOWN_IID(RpcStub
),
1688 ADD_KNOWN_IID(RunnableObject
),
1689 ADD_KNOWN_IID(RunningObjectTable
),
1690 ADD_KNOWN_IID(StdMarshalInfo
),
1691 ADD_KNOWN_IID(Storage
),
1692 ADD_KNOWN_IID(Stream
),
1693 ADD_KNOWN_IID(StubManager
),
1694 ADD_KNOWN_IID(Unknown
),
1695 ADD_KNOWN_IID(ViewObject
),
1696 ADD_KNOWN_IID(ViewObject2
),
1697 ADD_KNOWN_GUID(IID_IDispatch
),
1698 ADD_KNOWN_GUID(IID_IWebBrowser
),
1699 ADD_KNOWN_GUID(IID_IWebBrowserApp
),
1700 ADD_KNOWN_GUID(IID_IWebBrowser2
),
1701 ADD_KNOWN_GUID(IID_IWebBrowser
),
1702 ADD_KNOWN_GUID(DIID_DWebBrowserEvents2
),
1703 ADD_KNOWN_GUID(DIID_DWebBrowserEvents
),
1706 // don't clobber preprocessor name space
1707 #undef ADD_KNOWN_IID
1708 #undef ADD_KNOWN_GUID
1710 // try to find the interface in the table
1711 for ( size_t ui
= 0; ui
< WXSIZEOF(aKnownIids
); ui
++ )
1713 if ( riid
== *aKnownIids
[ui
].pIid
)
1715 return aKnownIids
[ui
].szName
;
1719 // unknown IID, just transform to string
1720 LPOLESTR str
= NULL
;
1721 StringFromIID(riid
, &str
);
1729 return "StringFromIID() error";