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
) wxConvUTF8
.cMB2WC(progId
).data());
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
));
271 // Get IOleInPlaceObject interface
272 hret
= m_oleInPlaceObject
.QueryInterface(IID_IOleInPlaceObject
, m_ActiveX
);
273 wxASSERT(SUCCEEDED(hret
));
277 m_oleObject
->GetMiscStatus(DVASPECT_CONTENT
, &dwMiscStatus
);
278 wxASSERT(SUCCEEDED(hret
));
280 // set client site first ?
281 if (dwMiscStatus
& OLEMISC_SETCLIENTSITEFIRST
)
282 m_oleObject
->SetClientSite(m_clientSite
);
286 wxAutoOleInterface
<IPersistStreamInit
>
287 pPersistStreamInit(IID_IPersistStreamInit
, m_oleObject
);
289 if (pPersistStreamInit
.Ok())
291 hret
= pPersistStreamInit
->InitNew();
292 WXOLE_WARN(hret
, "CreateActiveX::pPersistStreamInit->InitNew()");
296 m_docAdviseCookie
= 0;
297 hret
= m_oleObject
->Advise(adviseSink
, &m_docAdviseCookie
);
298 WXOLE_WARN(hret
, "m_oleObject->Advise(adviseSink, &m_docAdviseCookie),\"Advise\")");
299 m_oleObject
->SetHostNames(L
"wxActiveXContainer", NULL
);
300 OleSetContainedObject(m_oleObject
, TRUE
);
302 if (! (dwMiscStatus
& OLEMISC_SETCLIENTSITEFIRST
))
303 m_oleObject
->SetClientSite(m_clientSite
);
307 GetClientSize(&w
, &h
);
315 hret
= m_oleInPlaceObject
->GetWindow(&m_oleObjectHWND
);
316 WXOLE_WARN(hret
, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
318 ::SetActiveWindow(m_oleObjectHWND
);
321 if (! (dwMiscStatus
& OLEMISC_INVISIBLEATRUNTIME
))
324 m_oleInPlaceObject
->SetObjectRects(&posRect
, &posRect
);
326 hret
= m_oleObject
->DoVerb(OLEIVERB_INPLACEACTIVATE
, NULL
, m_clientSite
, 0, (HWND
)GetHWND(), &posRect
);
327 hret
= m_oleObject
->DoVerb(OLEIVERB_SHOW
, 0, m_clientSite
, 0, (HWND
)GetHWND(), &posRect
);
330 if (! m_oleObjectHWND
)
332 hret
= m_oleInPlaceObject
->GetWindow(&m_oleObjectHWND
);
333 WXOLE_WARN(hret
, "m_oleInPlaceObject->GetWindow(&m_oleObjectHWND)");
338 ::SetActiveWindow(m_oleObjectHWND
);
339 ::ShowWindow(m_oleObjectHWND
, SW_SHOW
);
343 void wxActiveX::CreateActiveX(LPOLESTR progId
)
346 if (CLSIDFromProgID(progId
, &clsid
) != S_OK
)
349 CreateActiveX(clsid
);
352 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
353 // Case Insensitive Map of Event names to eventTypes
354 // created dynamically at run time in:
355 // EVT_ACTIVEX(eventName, id, fn)
356 // we map the pointer to them so that:
357 // const wxEventType& RegisterActiveXEvent(wxString eventName);
358 // can return a const reference, which is neccessary for event tables
359 // probably should use a wxWindows hash table here, but I'm lazy ...
360 struct less_wxStringI
362 bool operator()(const wxString
& x
, const wxString
& y
) const
364 return x
.CmpNoCase(y
) < 0;
368 typedef map
<wxString
, wxEventType
*, less_wxStringI
> ActiveXEventMap
;
369 static ActiveXEventMap sg_eventMap
;
371 // one off class for automatic freeing of activeX eventtypes
372 class ActiveXEventMapFlusher
375 ~ActiveXEventMapFlusher()
377 ActiveXEventMap::iterator it
= sg_eventMap
.end();
378 while (it
!= sg_eventMap
.end())
386 static ActiveXEventMapFlusher s_dummyActiveXEventMapFlusher
;
388 const wxEventType
& RegisterActiveXEvent(wxString eventName
)
390 ActiveXEventMap::iterator it
= sg_eventMap
.find(eventName
);
391 if (it
== sg_eventMap
.end())
393 wxEventType
*et
= new wxEventType(wxNewEventType());
394 sg_eventMap
[eventName
] = et
;
399 return *(it
->second
);
402 //////////////////////////////////////////////////////
403 bool MSWVariantToVariant(VARIANTARG
& va
, wxVariant
& vx
)
407 case VT_VARIANT
| VT_BYREF
:
408 return MSWVariantToVariant(*va
.pvarVal
, vx
);
415 case VT_I2
| VT_BYREF
:
416 case VT_I4
| VT_BYREF
:
417 vx
= (long) *va
.piVal
;
421 vx
= wxString(va
.bstrVal
);
424 case VT_BSTR
| VT_BYREF
:
425 vx
= wxString(*va
.pbstrVal
);
429 vx
= (va
.boolVal
!= FALSE
);
432 case VT_BOOL
| VT_BYREF
:
433 vx
= (*va
.pboolVal
!= FALSE
);
442 bool VariantToMSWVariant(wxVariant
& vx
, VARIANTARG
& va
)
446 case VT_VARIANT
| VT_BYREF
:
447 return VariantToMSWVariant(vx
, va
);
454 case VT_I2
| VT_BYREF
:
455 case VT_I4
| VT_BYREF
:
456 *va
.piVal
= (long) vx
;
460 va
.boolVal
= ((bool) vx
) ? TRUE
: FALSE
;
463 case VT_BOOL
| VT_BYREF
:
464 *va
.pboolVal
= ((bool) vx
) ? TRUE
: FALSE
;
472 class wxActiveXEvents
: public IDispatch
475 DECLARE_OLE_UNKNOWN(wxActiveXEvents
);
478 wxActiveX
*m_activeX
;
481 wxActiveXEvents(wxActiveX
*ax
) : m_activeX(ax
) {}
487 STDMETHODIMP
GetIDsOfNames(REFIID r
, OLECHAR
** o
, unsigned int i
, LCID l
, DISPID
* d
)
492 STDMETHODIMP
GetTypeInfo(unsigned int i
, LCID l
, ITypeInfo
** t
)
497 STDMETHODIMP
GetTypeInfoCount(unsigned int* i
)
504 STDMETHODIMP
Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
505 WORD wFlags
, DISPPARAMS
* pDispParams
,
506 VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
,
507 unsigned int * puArgErr
)
509 if (wFlags
& (DISPATCH_PROPERTYGET
| DISPATCH_PROPERTYPUT
| DISPATCH_PROPERTYPUTREF
))
512 // map dispid to name
513 wxActiveX::MemberIdList::iterator mid
= m_activeX
->m_eventsIdx
.find((MEMBERID
) dispIdMember
);
514 if (mid
== m_activeX
->m_eventsIdx
.end())
517 int idx
= mid
->second
;
520 wxActiveX::FuncX
&func
= m_activeX
->m_events
[idx
];
522 ActiveXEventMap::iterator it
= sg_eventMap
.find(func
.name
);
523 if (it
== sg_eventMap
.end())
526 wxActiveXEvent event
;
527 event
.SetId(m_activeX
->GetId());
528 event
.SetEventType(*(it
->second
));
529 event
.m_params
.NullList();
535 for (int i
= pDispParams
->cArgs
- 1; i
>= 0; i
--)
537 VARIANTARG
& va
= pDispParams
->rgvarg
[i
];
538 wxActiveX::ParamX
&px
= func
.params
[pDispParams
->cArgs
- i
- 1];
541 MSWVariantToVariant(va
, vx
);
543 event
.m_params
.Append(vx
);
549 m_activeX
->GetParent()->ProcessEvent(event
);
550 for (unsigned int i
= 0; i
< pDispParams
->cArgs
; i
++)
552 VARIANTARG
& va
= pDispParams
->rgvarg
[i
];
553 wxActiveX::ParamX
&px
= func
.params
[pDispParams
->cArgs
- i
- 1];
557 wxVariant
& vx
= event
.m_params
[pDispParams
->cArgs
- i
- 1];
559 VariantToMSWVariant(vx
, va
);
564 m_activeX
->GetParent()->AddPendingEvent(event
);
571 DEFINE_OLE_TABLE(wxActiveXEvents
)
572 OLE_IINTERFACE(IUnknown
)
573 OLE_INTERFACE(IID_IDispatch
, IDispatch
)
577 int wxActiveXEvent::ParamCount() const
579 return m_params
.GetCount();
582 static wxVariant nullVar
;
584 wxVariant
wxActiveXEvent::operator[] (int idx
) const
586 return (wxVariant
&) operator[] (idx
);
589 wxVariant
& wxActiveXEvent::operator[] (int idx
)
591 wxASSERT(idx
>= 0 && idx
< ParamCount());
593 return m_params
[idx
];
596 wxVariant
wxActiveXEvent::operator[] (wxString name
) const
598 return (wxVariant
&) operator[] (name
);
601 wxVariant
& wxActiveXEvent::operator[] (wxString name
)
603 for (int i
= 0; i
< m_params
.GetCount(); i
++)
605 if (name
.CmpNoCase(m_params
[i
].GetName()) == 0)
609 wxString err
= "wxActiveXEvent::operator[] invalid name <" + name
+ ">";
610 err
+= "\r\nValid Names = :\r\n";
611 for (i
= 0; i
< m_params
.GetCount(); i
++)
613 err
+= m_params
[i
].GetName();
617 wxASSERT_MSG(false, err
);
622 void wxActiveX::GetTypeInfo()
625 We are currently only interested in the IDispatch interface
626 to the control. For dual interfaces (TypeKind = TKIND_INTERFACE)
627 we should drill down through the inheritance
628 (using TYPEATTR->cImplTypes) and GetRefTypeOfImplType(n)
629 and retrieve all the func names etc that way, then generate a C++
632 But we don't do this and probably never will, so if we have a DUAL
633 interface then we query for the IDispatch
634 via GetRefTypeOfImplType(-1).
639 // get type info via class info
640 wxAutoOleInterface
<IProvideClassInfo
> classInfo(IID_IProvideClassInfo
, m_ActiveX
);
641 if (! classInfo
.Ok())
645 wxAutoOleInterface
<ITypeInfo
> typeInfo
;
646 hret
= classInfo
->GetClassInfo(typeInfo
.GetRef());
652 hret
= typeInfo
->GetTypeAttr(&ta
);
656 // this should be a TKIND_COCLASS
657 wxASSERT(ta
->typekind
== TKIND_COCLASS
);
659 // iterate contained interfaces
660 for (int i
= 0; i
< ta
->cImplTypes
; i
++)
664 // get dispatch type info handle
665 hret
= typeInfo
->GetRefTypeOfImplType(i
, &rt
);
666 if (! SUCCEEDED(hret
))
669 // get dispatch type info interface
670 wxAutoOleInterface
<ITypeInfo
> ti
;
671 hret
= typeInfo
->GetRefTypeInfo(rt
, ti
.GetRef());
675 // check if default event sink
676 bool defEventSink
= false;
677 int impTypeFlags
= 0;
678 typeInfo
->GetImplTypeFlags(i
, &impTypeFlags
);
680 if (impTypeFlags
& IMPLTYPEFLAG_FDEFAULT
)
682 if (impTypeFlags
& IMPLTYPEFLAG_FSOURCE
)
684 WXOLE_TRACEOUT("Default Event Sink");
689 WXOLE_TRACEOUT("Default Interface");
695 GetTypeInfo(ti
, defEventSink
);
700 typeInfo
->ReleaseTypeAttr(ta
);
703 void wxActiveX::GetTypeInfo(ITypeInfo
*ti
, bool defEventSink
)
706 wxAutoOleInterface
<ITypeInfo
> typeInfo(ti
);
710 HRESULT hret
= typeInfo
->GetTypeAttr(&ta
);
714 if (ta
->typekind
== TKIND_DISPATCH
)
716 WXOLE_TRACEOUT("GUID = " << GetIIDName(ta
->guid
).c_str());
720 wxActiveXEvents
*disp
= new wxActiveXEvents(this);
721 ConnectAdvise(ta
->guid
, disp
);
725 // Get Function Names
726 for (int i
= 0; i
< ta
->cFuncs
; i
++)
728 FUNCDESC FAR
*fd
= NULL
;
730 hret
= typeInfo
->GetFuncDesc(i
, &fd
);
734 BSTR anames
[1] = {NULL
};
737 hret
= typeInfo
->GetNames(fd
->memid
, anames
, 1, &n
);
741 wxString name
= anames
[0];
743 WXOLE_TRACEOUT("Name " << i
<< " = " << name
.c_str());
744 SysFreeString(anames
[0]);
750 func
.memid
= fd
->memid
;
754 unsigned int maxPNames
= fd
->cParams
+ 1;
755 unsigned int nPNames
= 0;
756 BSTR
*pnames
= new BSTR
[maxPNames
];
758 hret
= typeInfo
->GetNames(fd
->memid
, pnames
, maxPNames
, &nPNames
);
760 SysFreeString(pnames
[0]);
762 for (int p
= 0; p
< fd
->cParams
; p
++)
765 param
.flags
= fd
->lprgelemdescParam
[p
].idldesc
.wIDLFlags
;
766 param
.vt
= fd
->lprgelemdescParam
[p
].tdesc
.vt
;
767 param
.name
= pnames
[p
+ 1];
768 SysFreeString(pnames
[p
+ 1]);
770 func
.hasOut
|= param
.IsOut();
771 func
.params
.push_back(param
);
775 m_events
.push_back(func
);
776 m_eventsIdx
[fd
->memid
] = m_events
.size() - 1;
780 typeInfo
->ReleaseFuncDesc(fd
);
784 typeInfo
->ReleaseTypeAttr(ta
);
787 HRESULT
wxActiveX::ConnectAdvise(REFIID riid
, IUnknown
*events
)
789 wxOleConnectionPoint cp
;
790 DWORD adviseCookie
= 0;
792 wxAutoOleInterface
<IConnectionPointContainer
> cpContainer(IID_IConnectionPointContainer
, m_ActiveX
);
793 if (! cpContainer
.Ok())
796 HRESULT hret
= cpContainer
->FindConnectionPoint(riid
, cp
.GetRef());
797 if (! SUCCEEDED(hret
))
800 hret
= cp
->Advise(events
, &adviseCookie
);
803 m_connections
.push_back(wxOleConnection(cp
, adviseCookie
));
808 HRESULT
wxActiveX::AmbientPropertyChanged(DISPID dispid
)
810 wxAutoOleInterface
<IOleControl
> oleControl(IID_IOleControl
, m_oleObject
);
813 return oleControl
->OnAmbientPropertyChange(dispid
);
818 #define HIMETRIC_PER_INCH 2540
819 #define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
821 static void PixelsToHimetric(SIZEL
&sz
)
829 HDC dc
= GetDC(NULL
);
830 logX
= GetDeviceCaps(dc
, LOGPIXELSX
);
831 logY
= GetDeviceCaps(dc
, LOGPIXELSY
);
835 #define HIMETRIC_INCH 2540
836 #define CONVERT(x, logpixels) MulDiv(HIMETRIC_INCH, (x), (logpixels))
838 sz
.cx
= CONVERT(sz
.cx
, logX
);
839 sz
.cy
= CONVERT(sz
.cy
, logY
);
846 void wxActiveX::OnSize(wxSizeEvent
& event
)
849 GetClientSize(&w
, &h
);
857 if (w
<= 0 && h
<= 0)
860 if (m_oleInPlaceObject
)
861 m_oleInPlaceObject
->SetObjectRects(&posRect
, &posRect
);
863 // extents are in HIMETRIC units
865 PixelsToHimetric(sz
);
868 m_oleObject
->GetExtent(DVASPECT_CONTENT
, &sz2
);
869 if (sz2
.cx
!= sz
.cx
|| sz
.cy
!= sz2
.cy
)
870 m_oleObject
->SetExtent(DVASPECT_CONTENT
, &sz
);
873 void wxActiveX::OnSetFocus(wxFocusEvent
& event
)
875 if (m_oleInPlaceActiveObject
.Ok())
876 m_oleInPlaceActiveObject
->OnFrameWindowActivate(TRUE
);
879 void wxActiveX::OnKillFocus(wxFocusEvent
& event
)
881 if (m_oleInPlaceActiveObject
.Ok())
882 m_oleInPlaceActiveObject
->OnFrameWindowActivate(FALSE
);
886 FrameSite::FrameSite(wxActiveX
* win
)
889 m_bSupportsWindowlessActivation
= true;
890 m_bInPlaceLocked
= false;
892 m_bInPlaceActive
= false;
893 m_bWindowless
= false;
895 m_nAmbientLocale
= 0;
896 m_clrAmbientForeColor
= ::GetSysColor(COLOR_WINDOWTEXT
);
897 m_clrAmbientBackColor
= ::GetSysColor(COLOR_WINDOW
);
898 m_bAmbientShowHatching
= true;
899 m_bAmbientShowGrabHandles
= true;
900 m_bAmbientAppearance
= true;
903 m_hWndParent
= (HWND
)m_window
->GetHWND();
906 FrameSite::~FrameSite()
913 HRESULT
FrameSite::GetIDsOfNames(REFIID riid
, OLECHAR
** rgszNames
, unsigned int cNames
,
914 LCID lcid
, DISPID
* rgDispId
)
916 WXOLE_TRACE("IDispatch::GetIDsOfNames");
920 HRESULT
FrameSite::GetTypeInfo(unsigned int iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
922 WXOLE_TRACE("IDispatch::GetTypeInfo");
926 HRESULT
FrameSite::GetTypeInfoCount(unsigned int * pcTInfo
)
928 WXOLE_TRACE("IDispatch::GetTypeInfoCount");
932 HRESULT
FrameSite::Invoke(DISPID dispIdMember
, REFIID riid
, LCID lcid
,
933 WORD wFlags
, DISPPARAMS
* pDispParams
,
934 VARIANT
* pVarResult
, EXCEPINFO
* pExcepInfo
,
935 unsigned int * puArgErr
)
937 WXOLE_TRACE("IDispatch::Invoke");
939 if (!(wFlags
& DISPATCH_PROPERTYGET
))
944 if (pVarResult
== NULL
)
947 //The most common case is boolean, use as an initial type
948 V_VT(pVarResult
) = VT_BOOL
;
950 switch (dispIdMember
)
952 case DISPID_AMBIENT_MESSAGEREFLECT
:
953 WXOLE_TRACE("Invoke::DISPID_AMBIENT_MESSAGEREFLECT");
954 V_BOOL(pVarResult
)= FALSE
;
957 case DISPID_AMBIENT_DISPLAYASDEFAULT
:
958 WXOLE_TRACE("Invoke::DISPID_AMBIENT_DISPLAYASDEFAULT");
959 V_BOOL(pVarResult
)= TRUE
;
962 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED
:
963 WXOLE_TRACE("Invoke::DISPID_AMBIENT_OFFLINEIFNOTCONNECTED");
964 V_BOOL(pVarResult
) = TRUE
;
968 case DISPID_AMBIENT_SILENT
:
969 WXOLE_TRACE("Invoke::DISPID_AMBIENT_SILENT");
970 V_BOOL(pVarResult
)= TRUE
;
973 case DISPID_AMBIENT_APPEARANCE
:
974 pVarResult
->vt
= VT_BOOL
;
975 pVarResult
->boolVal
= m_bAmbientAppearance
;
978 case DISPID_AMBIENT_FORECOLOR
:
979 pVarResult
->vt
= VT_I4
;
980 pVarResult
->lVal
= (long) m_clrAmbientForeColor
;
983 case DISPID_AMBIENT_BACKCOLOR
:
984 pVarResult
->vt
= VT_I4
;
985 pVarResult
->lVal
= (long) m_clrAmbientBackColor
;
988 case DISPID_AMBIENT_LOCALEID
:
989 pVarResult
->vt
= VT_I4
;
990 pVarResult
->lVal
= (long) m_nAmbientLocale
;
993 case DISPID_AMBIENT_USERMODE
:
994 pVarResult
->vt
= VT_BOOL
;
995 pVarResult
->boolVal
= m_window
->m_bAmbientUserMode
;
998 case DISPID_AMBIENT_SHOWGRABHANDLES
:
999 pVarResult
->vt
= VT_BOOL
;
1000 pVarResult
->boolVal
= m_bAmbientShowGrabHandles
;
1003 case DISPID_AMBIENT_SHOWHATCHING
:
1004 pVarResult
->vt
= VT_BOOL
;
1005 pVarResult
->boolVal
= m_bAmbientShowHatching
;
1009 return DISP_E_MEMBERNOTFOUND
;
1017 HRESULT
FrameSite::GetWindow(HWND
* phwnd
)
1019 WXOLE_TRACE("IOleWindow::GetWindow");
1021 return E_INVALIDARG
;
1022 (*phwnd
) = m_hWndParent
;
1026 HRESULT
FrameSite::ContextSensitiveHelp(BOOL fEnterMode
)
1028 WXOLE_TRACE("IOleWindow::ContextSensitiveHelp");
1032 //IOleInPlaceUIWindow
1034 HRESULT
FrameSite::GetBorder(LPRECT lprectBorder
)
1036 WXOLE_TRACE("IOleInPlaceUIWindow::GetBorder");
1037 if (lprectBorder
== NULL
)
1038 return E_INVALIDARG
;
1039 return INPLACE_E_NOTOOLSPACE
;
1042 HRESULT
FrameSite::RequestBorderSpace(LPCBORDERWIDTHS pborderwidths
)
1044 WXOLE_TRACE("IOleInPlaceUIWindow::RequestBorderSpace");
1045 if (pborderwidths
== NULL
)
1046 return E_INVALIDARG
;
1047 return INPLACE_E_NOTOOLSPACE
;
1050 HRESULT
FrameSite::SetBorderSpace(LPCBORDERWIDTHS pborderwidths
)
1052 WXOLE_TRACE("IOleInPlaceUIWindow::SetBorderSpace");
1056 HRESULT
FrameSite::SetActiveObject(IOleInPlaceActiveObject
*pActiveObject
, LPCOLESTR pszObjName
)
1058 WXOLE_TRACE("IOleInPlaceUIWindow::SetActiveObject");
1061 pActiveObject
->AddRef();
1063 m_window
->m_oleInPlaceActiveObject
= pActiveObject
;
1069 HRESULT
FrameSite::InsertMenus(HMENU hmenuShared
, LPOLEMENUGROUPWIDTHS lpMenuWidths
)
1071 WXOLE_TRACE("IOleInPlaceFrame::InsertMenus");
1075 HRESULT
FrameSite::SetMenu(HMENU hmenuShared
, HOLEMENU holemenu
, HWND hwndActiveObject
)
1077 WXOLE_TRACE("IOleInPlaceFrame::SetMenu");
1081 HRESULT
FrameSite::RemoveMenus(HMENU hmenuShared
)
1083 WXOLE_TRACE("IOleInPlaceFrame::RemoveMenus");
1087 HRESULT
FrameSite::SetStatusText(LPCOLESTR pszStatusText
)
1089 WXOLE_TRACE("IOleInPlaceFrame::SetStatusText");
1090 //((wxFrame*)wxGetApp().GetTopWindow())->GetStatusBar()->SetStatusText(pszStatusText);
1094 HRESULT
FrameSite::EnableModeless(BOOL fEnable
)
1096 WXOLE_TRACE("IOleInPlaceFrame::EnableModeless");
1100 HRESULT
FrameSite::TranslateAccelerator(LPMSG lpmsg
, WORD wID
)
1102 WXOLE_TRACE("IOleInPlaceFrame::TranslateAccelerator");
1103 // TODO: send an event with this id
1104 if (m_window
->m_oleInPlaceActiveObject
.Ok())
1105 m_window
->m_oleInPlaceActiveObject
->TranslateAccelerator(lpmsg
);
1112 HRESULT
FrameSite::CanInPlaceActivate()
1114 WXOLE_TRACE("IOleInPlaceSite::CanInPlaceActivate");
1118 HRESULT
FrameSite::OnInPlaceActivate()
1120 WXOLE_TRACE("IOleInPlaceSite::OnInPlaceActivate");
1121 m_bInPlaceActive
= true;
1125 HRESULT
FrameSite::OnUIActivate()
1127 WXOLE_TRACE("IOleInPlaceSite::OnUIActivate");
1132 HRESULT
FrameSite::GetWindowContext(IOleInPlaceFrame
**ppFrame
,
1133 IOleInPlaceUIWindow
**ppDoc
,
1135 LPRECT lprcClipRect
,
1136 LPOLEINPLACEFRAMEINFO lpFrameInfo
)
1138 WXOLE_TRACE("IOleInPlaceSite::GetWindowContext");
1139 if (ppFrame
== NULL
|| ppDoc
== NULL
|| lprcPosRect
== NULL
||
1140 lprcClipRect
== NULL
|| lpFrameInfo
== NULL
)
1142 if (ppFrame
!= NULL
)
1146 return E_INVALIDARG
;
1149 HRESULT hr
= QueryInterface(IID_IOleInPlaceFrame
, (void **) ppFrame
);
1150 if (! SUCCEEDED(hr
))
1152 WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceFrame Error !");
1153 return E_UNEXPECTED
;
1156 hr
= QueryInterface(IID_IOleInPlaceUIWindow
, (void **) ppDoc
);
1157 if (! SUCCEEDED(hr
))
1159 WXOLE_TRACE("IOleInPlaceSite::IOleInPlaceUIWindow Error !");
1160 (*ppFrame
)->Release();
1162 return E_UNEXPECTED
;
1166 m_window
->GetClientSize(&w
, &h
);
1169 lprcPosRect
->left
= lprcPosRect
->top
= 0;
1170 lprcPosRect
->right
= w
;
1171 lprcPosRect
->bottom
= h
;
1175 lprcClipRect
->left
= lprcClipRect
->top
= 0;
1176 lprcClipRect
->right
= w
;
1177 lprcClipRect
->bottom
= h
;
1180 memset(lpFrameInfo
, 0, sizeof(OLEINPLACEFRAMEINFO
));
1181 lpFrameInfo
->cb
= sizeof(OLEINPLACEFRAMEINFO
);
1182 lpFrameInfo
->hwndFrame
= m_hWndParent
;
1187 HRESULT
FrameSite::Scroll(SIZE scrollExtent
)
1189 WXOLE_TRACE("IOleInPlaceSite::Scroll");
1193 HRESULT
FrameSite::OnUIDeactivate(BOOL fUndoable
)
1195 WXOLE_TRACE("IOleInPlaceSite::OnUIDeactivate");
1196 m_bUIActive
= false;
1200 HRESULT
FrameSite::OnInPlaceDeactivate()
1202 WXOLE_TRACE("IOleInPlaceSite::OnInPlaceDeactivate");
1203 m_bInPlaceActive
= false;
1207 HRESULT
FrameSite::DiscardUndoState()
1209 WXOLE_TRACE("IOleInPlaceSite::DiscardUndoState");
1213 HRESULT
FrameSite::DeactivateAndUndo()
1215 WXOLE_TRACE("IOleInPlaceSite::DeactivateAndUndo");
1219 HRESULT
FrameSite::OnPosRectChange(LPCRECT lprcPosRect
)
1221 WXOLE_TRACE("IOleInPlaceSite::OnPosRectChange");
1222 if (m_window
->m_oleInPlaceObject
.Ok() && lprcPosRect
)
1223 m_window
->m_oleInPlaceObject
->SetObjectRects(lprcPosRect
, lprcPosRect
);
1230 HRESULT
FrameSite::OnInPlaceActivateEx(BOOL
* pfNoRedraw
, DWORD dwFlags
)
1232 WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceActivateEx");
1233 OleLockRunning(m_window
->m_ActiveX
, TRUE
, FALSE
);
1235 (*pfNoRedraw
) = FALSE
;
1239 HRESULT
FrameSite::OnInPlaceDeactivateEx(BOOL fNoRedraw
)
1241 WXOLE_TRACE("IOleInPlaceSiteEx::OnInPlaceDeactivateEx");
1242 OleLockRunning(m_window
->m_ActiveX
, FALSE
, FALSE
);
1246 HRESULT
FrameSite::RequestUIActivate()
1248 WXOLE_TRACE("IOleInPlaceSiteEx::RequestUIActivate");
1255 HRESULT
FrameSite::SaveObject()
1257 WXOLE_TRACE("IOleClientSite::SaveObject");
1261 HRESULT
FrameSite::GetMoniker(DWORD dwAssign
, DWORD dwWhichMoniker
,
1264 WXOLE_TRACE("IOleClientSite::GetMoniker");
1268 HRESULT
FrameSite::GetContainer(LPOLECONTAINER
* ppContainer
)
1270 WXOLE_TRACE("IOleClientSite::GetContainer");
1271 if (ppContainer
== NULL
)
1272 return E_INVALIDARG
;
1274 HRESULT hr
= QueryInterface(IID_IOleContainer
, (void**)(ppContainer
));
1275 wxASSERT(SUCCEEDED(hr
));
1280 HRESULT
FrameSite::ShowObject()
1282 WXOLE_TRACE("IOleClientSite::ShowObject");
1283 if (m_window
->m_oleObjectHWND
)
1284 ::ShowWindow(m_window
->m_oleObjectHWND
, SW_SHOW
);
1288 HRESULT
FrameSite::OnShowWindow(BOOL fShow
)
1290 WXOLE_TRACE("IOleClientSite::OnShowWindow");
1294 HRESULT
FrameSite::RequestNewObjectLayout()
1296 WXOLE_TRACE("IOleClientSite::RequestNewObjectLayout");
1300 // IParseDisplayName
1302 HRESULT
FrameSite::ParseDisplayName(IBindCtx
*pbc
, LPOLESTR pszDisplayName
,
1303 ULONG
*pchEaten
, IMoniker
**ppmkOut
)
1305 WXOLE_TRACE("IParseDisplayName::ParseDisplayName");
1311 HRESULT
FrameSite::EnumObjects(DWORD grfFlags
, IEnumUnknown
**ppenum
)
1313 WXOLE_TRACE("IOleContainer::EnumObjects");
1317 HRESULT
FrameSite::LockContainer(BOOL fLock
)
1319 WXOLE_TRACE("IOleContainer::LockContainer");
1326 HRESULT
FrameSite::GetObject(LPOLESTR pszItem
, DWORD dwSpeedNeeded
,
1327 IBindCtx
* pbc
, REFIID riid
, void ** ppvObject
)
1329 WXOLE_TRACE("IOleItemContainer::GetObject");
1330 if (pszItem
== NULL
)
1331 return E_INVALIDARG
;
1332 if (ppvObject
== NULL
)
1333 return E_INVALIDARG
;
1336 return MK_E_NOOBJECT
;
1339 HRESULT
FrameSite::GetObjectStorage(LPOLESTR pszItem
, IBindCtx
* pbc
,
1340 REFIID riid
, void ** ppvStorage
)
1342 WXOLE_TRACE("IOleItemContainer::GetObjectStorage");
1343 if (pszItem
== NULL
)
1344 return E_INVALIDARG
;
1345 if (ppvStorage
== NULL
)
1346 return E_INVALIDARG
;
1349 return MK_E_NOOBJECT
;
1352 HRESULT
FrameSite::IsRunning(LPOLESTR pszItem
)
1354 WXOLE_TRACE("IOleItemContainer::IsRunning");
1355 if (pszItem
== NULL
)
1356 return E_INVALIDARG
;
1358 return MK_E_NOOBJECT
;
1365 HRESULT
FrameSite::OnControlInfoChanged()
1367 WXOLE_TRACE("IOleControlSite::OnControlInfoChanged");
1371 HRESULT
FrameSite::LockInPlaceActive(BOOL fLock
)
1373 WXOLE_TRACE("IOleControlSite::LockInPlaceActive");
1374 m_bInPlaceLocked
= (fLock
) ? true : false;
1378 HRESULT
FrameSite::GetExtendedControl(IDispatch
** ppDisp
)
1380 WXOLE_TRACE("IOleControlSite::GetExtendedControl");
1384 HRESULT
FrameSite::TransformCoords(POINTL
* pPtlHimetric
, POINTF
* pPtfContainer
, DWORD dwFlags
)
1386 WXOLE_TRACE("IOleControlSite::TransformCoords");
1389 if (pPtlHimetric
== NULL
)
1390 return E_INVALIDARG
;
1392 if (pPtfContainer
== NULL
)
1393 return E_INVALIDARG
;
1399 HRESULT
FrameSite::TranslateAccelerator(LPMSG pMsg
, DWORD grfModifiers
)
1401 WXOLE_TRACE("IOleControlSite::TranslateAccelerator");
1402 // TODO: send an event with this id
1406 HRESULT
FrameSite::OnFocus(BOOL fGotFocus
)
1408 WXOLE_TRACE("IOleControlSite::OnFocus");
1412 HRESULT
FrameSite::ShowPropertyFrame()
1414 WXOLE_TRACE("IOleControlSite::ShowPropertyFrame");
1420 HRESULT
FrameSite::QueryStatus(const GUID
* pguidCmdGroup
, ULONG cCmds
,
1421 OLECMD
* prgCmds
, OLECMDTEXT
* pCmdTet
)
1423 WXOLE_TRACE("IOleCommandTarget::QueryStatus");
1424 if (prgCmds
== NULL
) return E_INVALIDARG
;
1425 bool bCmdGroupFound
= false;
1427 for (ULONG nCmd
= 0; nCmd
< cCmds
; nCmd
++)
1429 // unsupported by default
1430 prgCmds
[nCmd
].cmdf
= 0;
1435 if (!bCmdGroupFound
) { OLECMDERR_E_UNKNOWNGROUP
; }
1439 HRESULT
FrameSite::Exec(const GUID
* pguidCmdGroup
, DWORD nCmdID
,
1440 DWORD nCmdExecOpt
, VARIANTARG
* pVaIn
,
1441 VARIANTARG
* pVaOut
)
1443 WXOLE_TRACE("IOleCommandTarget::Exec");
1444 bool bCmdGroupFound
= false;
1446 if (!bCmdGroupFound
) { OLECMDERR_E_UNKNOWNGROUP
; }
1447 return OLECMDERR_E_NOTSUPPORTED
;
1452 void STDMETHODCALLTYPE
FrameSite::OnDataChange(FORMATETC
* pFormatEtc
, STGMEDIUM
* pgStgMed
)
1454 WXOLE_TRACE("IAdviseSink::OnDataChange");
1457 void STDMETHODCALLTYPE
FrameSite::OnViewChange(DWORD dwAspect
, LONG lIndex
)
1459 WXOLE_TRACE("IAdviseSink::OnViewChange");
1460 // redraw the control
1463 void STDMETHODCALLTYPE
FrameSite::OnRename(IMoniker
* pmk
)
1465 WXOLE_TRACE("IAdviseSink::OnRename");
1468 void STDMETHODCALLTYPE
FrameSite::OnSave()
1470 WXOLE_TRACE("IAdviseSink::OnSave");
1473 void STDMETHODCALLTYPE
FrameSite::OnClose()
1475 WXOLE_TRACE("IAdviseSink::OnClose");
1478 /////////////////////////////////////////////
1480 HRESULT STDMETHODCALLTYPE
FrameSite::ActivateMe(
1481 /* [in] */ IOleDocumentView __RPC_FAR
*pViewToActivate
)
1483 wxAutoOleInterface
<IOleInPlaceSite
> inPlaceSite(IID_IOleInPlaceSite
, (IDispatch
*) this);
1484 if (!inPlaceSite
.Ok())
1487 if (pViewToActivate
)
1489 m_window
->m_docView
= pViewToActivate
;
1490 m_window
->m_docView
->SetInPlaceSite(inPlaceSite
);
1494 wxAutoOleInterface
<IOleDocument
> oleDoc(IID_IOleDocument
, m_window
->m_oleObject
);
1498 HRESULT hr
= oleDoc
->CreateView(inPlaceSite
, NULL
, 0, m_window
->m_docView
.GetRef());
1502 m_window
->m_docView
->SetInPlaceSite(inPlaceSite
);
1505 m_window
->m_docView
->UIActivate(TRUE
);
1512 static IMalloc
*iMalloc
= NULL
;
1514 IMalloc
*wxOleInit::GetIMalloc()
1520 wxOleInit::wxOleInit()
1522 if (OleInitialize(NULL
) == S_OK
&& iMalloc
== NULL
)
1523 CoGetMalloc(1, &iMalloc
);
1528 wxOleInit::~wxOleInit()
1532 if (iMalloc
->Release() == 0)
1539 wxString
OLEHResultToString(HRESULT hr
)
1546 case OLECMDERR_E_UNKNOWNGROUP
:
1547 return "The pguidCmdGroup parameter is not NULL but does not specify a recognized command group.";
1549 case OLECMDERR_E_NOTSUPPORTED
:
1550 return "The nCmdID parameter is not a valid command in the group identified by pguidCmdGroup.";
1552 case OLECMDERR_E_DISABLED
:
1553 return "The command identified by nCmdID is currently disabled and cannot be executed.";
1555 case OLECMDERR_E_NOHELP
:
1556 return "The caller has asked for help on the command identified by nCmdID, but no help is available.";
1558 case OLECMDERR_E_CANCELED
:
1559 return "The user canceled the execution of the command.";
1562 return "E_INVALIDARG";
1565 return "E_OUTOFMEMORY";
1568 return "E_NOINTERFACE";
1571 return "E_UNEXPECTED";
1573 case STG_E_INVALIDFLAG
:
1574 return "STG_E_INVALIDFLAG";
1585 sprintf(buf
, "Unknown - 0x%X", hr
);
1586 return wxString(buf
);
1591 // borrowed from src/msw/ole/oleutils.cpp
1592 wxString
GetIIDName(REFIID riid
)
1594 // an association between symbolic name and numeric value of an IID
1598 const wxChar
*szName
;
1601 // construct the table containing all known interfaces
1602 #define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }
1603 #define ADD_KNOWN_GUID(name) { &name, _T(#name) }
1605 static const KNOWN_IID aKnownIids
[] =
1607 ADD_KNOWN_IID(AdviseSink
),
1608 ADD_KNOWN_IID(AdviseSink2
),
1609 ADD_KNOWN_IID(BindCtx
),
1610 ADD_KNOWN_IID(ClassFactory
),
1611 #if ( !defined( __VISUALC__) || (__VISUALC__!=1010) ) && !defined(__MWERKS__)
1612 ADD_KNOWN_IID(ContinueCallback
),
1613 ADD_KNOWN_IID(EnumOleDocumentViews
),
1614 ADD_KNOWN_IID(OleCommandTarget
),
1615 ADD_KNOWN_IID(OleDocument
),
1616 ADD_KNOWN_IID(OleDocumentSite
),
1617 ADD_KNOWN_IID(OleDocumentView
),
1618 ADD_KNOWN_IID(Print
),
1620 ADD_KNOWN_IID(DataAdviseHolder
),
1621 ADD_KNOWN_IID(DataObject
),
1622 ADD_KNOWN_IID(Debug
),
1623 ADD_KNOWN_IID(DebugStream
),
1624 ADD_KNOWN_IID(DfReserved1
),
1625 ADD_KNOWN_IID(DfReserved2
),
1626 ADD_KNOWN_IID(DfReserved3
),
1627 ADD_KNOWN_IID(Dispatch
),
1628 ADD_KNOWN_IID(DropSource
),
1629 ADD_KNOWN_IID(DropTarget
),
1630 ADD_KNOWN_IID(EnumCallback
),
1631 ADD_KNOWN_IID(EnumFORMATETC
),
1632 ADD_KNOWN_IID(EnumGeneric
),
1633 ADD_KNOWN_IID(EnumHolder
),
1634 ADD_KNOWN_IID(EnumMoniker
),
1635 ADD_KNOWN_IID(EnumOLEVERB
),
1636 ADD_KNOWN_IID(EnumSTATDATA
),
1637 ADD_KNOWN_IID(EnumSTATSTG
),
1638 ADD_KNOWN_IID(EnumString
),
1639 ADD_KNOWN_IID(EnumUnknown
),
1640 ADD_KNOWN_IID(EnumVARIANT
),
1641 ADD_KNOWN_IID(ExternalConnection
),
1642 ADD_KNOWN_IID(InternalMoniker
),
1643 ADD_KNOWN_IID(LockBytes
),
1644 ADD_KNOWN_IID(Malloc
),
1645 ADD_KNOWN_IID(Marshal
),
1646 ADD_KNOWN_IID(MessageFilter
),
1647 ADD_KNOWN_IID(Moniker
),
1648 ADD_KNOWN_IID(OleAdviseHolder
),
1649 ADD_KNOWN_IID(OleCache
),
1650 ADD_KNOWN_IID(OleCache2
),
1651 ADD_KNOWN_IID(OleCacheControl
),
1652 ADD_KNOWN_IID(OleClientSite
),
1653 ADD_KNOWN_IID(OleContainer
),
1654 ADD_KNOWN_IID(OleInPlaceActiveObject
),
1655 ADD_KNOWN_IID(OleInPlaceFrame
),
1656 ADD_KNOWN_IID(OleInPlaceObject
),
1657 ADD_KNOWN_IID(OleInPlaceSite
),
1658 ADD_KNOWN_IID(OleInPlaceUIWindow
),
1659 ADD_KNOWN_IID(OleItemContainer
),
1660 ADD_KNOWN_IID(OleLink
),
1661 ADD_KNOWN_IID(OleManager
),
1662 ADD_KNOWN_IID(OleObject
),
1663 ADD_KNOWN_IID(OlePresObj
),
1664 ADD_KNOWN_IID(OleWindow
),
1665 ADD_KNOWN_IID(PSFactory
),
1666 ADD_KNOWN_IID(ParseDisplayName
),
1667 ADD_KNOWN_IID(Persist
),
1668 ADD_KNOWN_IID(PersistFile
),
1669 ADD_KNOWN_IID(PersistStorage
),
1670 ADD_KNOWN_IID(PersistStream
),
1671 ADD_KNOWN_IID(ProxyManager
),
1672 ADD_KNOWN_IID(RootStorage
),
1673 ADD_KNOWN_IID(RpcChannel
),
1674 ADD_KNOWN_IID(RpcProxy
),
1675 ADD_KNOWN_IID(RpcStub
),
1676 ADD_KNOWN_IID(RunnableObject
),
1677 ADD_KNOWN_IID(RunningObjectTable
),
1678 ADD_KNOWN_IID(StdMarshalInfo
),
1679 ADD_KNOWN_IID(Storage
),
1680 ADD_KNOWN_IID(Stream
),
1681 ADD_KNOWN_IID(StubManager
),
1682 ADD_KNOWN_IID(Unknown
),
1683 ADD_KNOWN_IID(ViewObject
),
1684 ADD_KNOWN_IID(ViewObject2
),
1685 ADD_KNOWN_GUID(IID_IDispatch
),
1686 ADD_KNOWN_GUID(IID_IWebBrowser
),
1687 ADD_KNOWN_GUID(IID_IWebBrowserApp
),
1688 ADD_KNOWN_GUID(IID_IWebBrowser2
),
1689 ADD_KNOWN_GUID(IID_IWebBrowser
),
1690 ADD_KNOWN_GUID(DIID_DWebBrowserEvents2
),
1691 ADD_KNOWN_GUID(DIID_DWebBrowserEvents
),
1694 // don't clobber preprocessor name space
1695 #undef ADD_KNOWN_IID
1696 #undef ADD_KNOWN_GUID
1698 // try to find the interface in the table
1699 for ( size_t ui
= 0; ui
< WXSIZEOF(aKnownIids
); ui
++ )
1701 if ( riid
== *aKnownIids
[ui
].pIid
)
1703 return aKnownIids
[ui
].szName
;
1707 // unknown IID, just transform to string
1708 LPOLESTR str
= NULL
;
1709 StringFromIID(riid
, &str
);
1717 return "StringFromIID() error";