]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/msw/ole/activex.cpp
fixing osx_cocoa
[wxWidgets.git] / src / msw / ole / activex.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/ole/activex.cpp
3// Purpose: wxActiveXContainer implementation
4// Author: Ryan Norton <wxprojects@comcast.net>, Lindsay Mathieson <???>
5// Modified by:
6// Created: 11/07/04
7// RCS-ID: $Id$
8// Copyright: (c) 2003 Lindsay Mathieson, (c) 2005 Ryan Norton
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#if wxUSE_ACTIVEX
27
28#ifndef WX_PRECOMP
29 #include "wx/dcclient.h"
30 #include "wx/math.h"
31#endif
32
33#include "wx/msw/dc.h"
34
35#include "wx/msw/ole/activex.h"
36#include "wx/msw/private.h" // for wxCopyRectToRECT
37
38// autointerfaces that we only use here
39typedef wxAutoOleInterface<IOleInPlaceSite> wxAutoIOleInPlaceSite;
40typedef wxAutoOleInterface<IOleDocument> wxAutoIOleDocument;
41typedef wxAutoOleInterface<IPersistStreamInit> wxAutoIPersistStreamInit;
42typedef wxAutoOleInterface<IAdviseSink> wxAutoIAdviseSink;
43typedef wxAutoOleInterface<IProvideClassInfo> wxAutoIProvideClassInfo;
44typedef wxAutoOleInterface<ITypeInfo> wxAutoITypeInfo;
45typedef wxAutoOleInterface<IConnectionPoint> wxAutoIConnectionPoint;
46typedef wxAutoOleInterface<IConnectionPointContainer> wxAutoIConnectionPointContainer;
47
48wxDEFINE_EVENT( wxEVT_ACTIVEX, wxActiveXEvent );
49
50// Ole class helpers (sort of MFC-like) from wxActiveX
51#define DECLARE_OLE_UNKNOWN(cls)\
52 private:\
53 class TAutoInitInt\
54 {\
55 public:\
56 LONG l;\
57 TAutoInitInt() : l(1) {}\
58 };\
59 TAutoInitInt refCount, lockCount;\
60 static void _GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc);\
61 public:\
62 LONG GetRefCount();\
63 HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject);\
64 ULONG STDMETHODCALLTYPE AddRef();\
65 ULONG STDMETHODCALLTYPE Release();\
66 ULONG STDMETHODCALLTYPE AddLock();\
67 ULONG STDMETHODCALLTYPE ReleaseLock()
68
69#define DEFINE_OLE_TABLE(cls)\
70 LONG cls::GetRefCount() {return refCount.l;}\
71 HRESULT STDMETHODCALLTYPE cls::QueryInterface(REFIID iid, void ** ppvObject)\
72 {\
73 if (! ppvObject)\
74 {\
75 return E_FAIL;\
76 }\
77 const char *desc = NULL;\
78 cls::_GetInterface(this, iid, ppvObject, desc);\
79 if (! *ppvObject)\
80 {\
81 return E_NOINTERFACE;\
82 }\
83 ((IUnknown * )(*ppvObject))->AddRef();\
84 return S_OK;\
85 }\
86 ULONG STDMETHODCALLTYPE cls::AddRef()\
87 {\
88 InterlockedIncrement(&refCount.l);\
89 return refCount.l;\
90 }\
91 ULONG STDMETHODCALLTYPE cls::Release()\
92 {\
93 if (refCount.l > 0)\
94 {\
95 InterlockedDecrement(&refCount.l);\
96 if (refCount.l == 0)\
97 {\
98 delete this;\
99 return 0;\
100 }\
101 return refCount.l;\
102 }\
103 else\
104 return 0;\
105 }\
106 ULONG STDMETHODCALLTYPE cls::AddLock()\
107 {\
108 InterlockedIncrement(&lockCount.l);\
109 return lockCount.l;\
110 }\
111 ULONG STDMETHODCALLTYPE cls::ReleaseLock()\
112 {\
113 if (lockCount.l > 0)\
114 {\
115 InterlockedDecrement(&lockCount.l);\
116 return lockCount.l;\
117 }\
118 else\
119 return 0;\
120 }\
121 DEFINE_OLE_BASE(cls)
122
123#define DEFINE_OLE_BASE(cls)\
124 void cls::_GetInterface(cls *self, REFIID iid, void **_interface, const char *&desc)\
125 {\
126 *_interface = NULL;\
127 desc = NULL;
128
129#define OLE_INTERFACE(_iid, _type)\
130 if (IsEqualIID(iid, _iid))\
131 {\
132 *_interface = (IUnknown *) (_type *) self;\
133 desc = # _iid;\
134 return;\
135 }
136
137#define OLE_IINTERFACE(_face) OLE_INTERFACE(IID_##_face, _face)
138
139#define OLE_INTERFACE_CUSTOM(func)\
140 if (func(self, iid, _interface, desc))\
141 {\
142 return;\
143 }
144
145#define END_OLE_TABLE\
146 }
147
148// ============================================================================
149// implementation
150// ============================================================================
151
152//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
153// PixelsToHimetric
154//
155// Utility to convert from pixels to the himetric values in some COM methods
156//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
157
158
159#define HIMETRIC_PER_INCH 2540
160#define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
161
162static void PixelsToHimetric(SIZEL &sz)
163{
164 static int logX = 0;
165 static int logY = 0;
166
167 if (logY == 0)
168 {
169 // initaliase
170 HDC dc = GetDC(NULL);
171 logX = GetDeviceCaps(dc, LOGPIXELSX);
172 logY = GetDeviceCaps(dc, LOGPIXELSY);
173 ReleaseDC(NULL, dc);
174 };
175
176#define HIMETRIC_INCH 2540
177#define CONVERT(x, logpixels) wxMulDivInt32(HIMETRIC_INCH, (x), (logpixels))
178
179 sz.cx = CONVERT(sz.cx, logX);
180 sz.cy = CONVERT(sz.cy, logY);
181
182#undef CONVERT
183#undef HIMETRIC_INCH
184}
185
186
187//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
188//
189// FrameSite
190//
191// Handles the actual wxActiveX container implementation
192//
193//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
194class FrameSite :
195 public IOleClientSite,
196 public IOleInPlaceSiteEx,
197 public IOleInPlaceFrame,
198 public IOleItemContainer,
199 public IDispatch,
200 public IOleCommandTarget,
201 public IOleDocumentSite,
202 public IAdviseSink,
203 public IOleControlSite
204{
205private:
206 DECLARE_OLE_UNKNOWN(FrameSite);
207
208public:
209 FrameSite(wxWindow * win, wxActiveXContainer * win2)
210 {
211 m_window = win2;
212 m_bSupportsWindowlessActivation = true;
213 m_bInPlaceLocked = false;
214 m_bUIActive = false;
215 m_bInPlaceActive = false;
216 m_bWindowless = false;
217
218 m_nAmbientLocale = 0;
219 m_clrAmbientForeColor = ::GetSysColor(COLOR_WINDOWTEXT);
220 m_clrAmbientBackColor = ::GetSysColor(COLOR_WINDOW);
221 m_bAmbientShowHatching = true;
222 m_bAmbientShowGrabHandles = true;
223 m_bAmbientAppearance = true;
224
225 m_hDCBuffer = NULL;
226 m_hWndParent = (HWND)win->GetHWND();
227 }
228 virtual ~FrameSite(){}
229 //***************************IDispatch*****************************
230 HRESULT STDMETHODCALLTYPE GetIDsOfNames(REFIID, OLECHAR ** ,
231 unsigned int , LCID ,
232 DISPID * )
233 { return E_NOTIMPL; }
234 STDMETHOD(GetTypeInfo)(unsigned int, LCID, ITypeInfo **)
235 { return E_NOTIMPL; }
236 HRESULT STDMETHODCALLTYPE GetTypeInfoCount(unsigned int *)
237 { return E_NOTIMPL; }
238 HRESULT STDMETHODCALLTYPE Invoke(DISPID dispIdMember, REFIID, LCID,
239 WORD wFlags, DISPPARAMS *,
240 VARIANT * pVarResult, EXCEPINFO *,
241 unsigned int *)
242 {
243 if (!(wFlags & DISPATCH_PROPERTYGET))
244 return S_OK;
245
246 if (pVarResult == NULL)
247 return E_INVALIDARG;
248
249 //The most common case is boolean, use as an initial type
250 V_VT(pVarResult) = VT_BOOL;
251
252 switch (dispIdMember)
253 {
254 case DISPID_AMBIENT_MESSAGEREFLECT:
255 V_BOOL(pVarResult)= FALSE;
256 return S_OK;
257
258 case DISPID_AMBIENT_DISPLAYASDEFAULT:
259 V_BOOL(pVarResult)= TRUE;
260 return S_OK;
261
262 case DISPID_AMBIENT_OFFLINEIFNOTCONNECTED:
263 V_BOOL(pVarResult) = TRUE;
264 return S_OK;
265
266 case DISPID_AMBIENT_SILENT:
267 V_BOOL(pVarResult)= TRUE;
268 return S_OK;
269
270 case DISPID_AMBIENT_APPEARANCE:
271 pVarResult->vt = VT_BOOL;
272 pVarResult->boolVal = m_bAmbientAppearance;
273 break;
274
275 case DISPID_AMBIENT_FORECOLOR:
276 pVarResult->vt = VT_I4;
277 pVarResult->lVal = (long) m_clrAmbientForeColor;
278 break;
279
280 case DISPID_AMBIENT_BACKCOLOR:
281 pVarResult->vt = VT_I4;
282 pVarResult->lVal = (long) m_clrAmbientBackColor;
283 break;
284
285 case DISPID_AMBIENT_LOCALEID:
286 pVarResult->vt = VT_I4;
287 pVarResult->lVal = (long) m_nAmbientLocale;
288 break;
289
290 case DISPID_AMBIENT_USERMODE:
291 pVarResult->vt = VT_BOOL;
292 pVarResult->boolVal = m_window->m_bAmbientUserMode;
293 break;
294
295 case DISPID_AMBIENT_SHOWGRABHANDLES:
296 pVarResult->vt = VT_BOOL;
297 pVarResult->boolVal = m_bAmbientShowGrabHandles;
298 break;
299
300 case DISPID_AMBIENT_SHOWHATCHING:
301 pVarResult->vt = VT_BOOL;
302 pVarResult->boolVal = m_bAmbientShowHatching;
303 break;
304
305 default:
306 return DISP_E_MEMBERNOTFOUND;
307 }
308
309 return S_OK;
310 }
311
312 //**************************IOleWindow***************************
313 HRESULT STDMETHODCALLTYPE GetWindow(HWND * phwnd)
314 {
315 if (phwnd == NULL)
316 return E_INVALIDARG;
317 (*phwnd) = m_hWndParent;
318 return S_OK;
319 }
320 HRESULT STDMETHODCALLTYPE ContextSensitiveHelp(BOOL)
321 {return S_OK;}
322 //**************************IOleInPlaceUIWindow*****************
323 HRESULT STDMETHODCALLTYPE GetBorder(LPRECT lprectBorder)
324 {
325 if (lprectBorder == NULL)
326 return E_INVALIDARG;
327 return INPLACE_E_NOTOOLSPACE;
328 }
329 HRESULT STDMETHODCALLTYPE RequestBorderSpace(LPCBORDERWIDTHS pborderwidths)
330 {
331 if (pborderwidths == NULL)
332 return E_INVALIDARG;
333 return INPLACE_E_NOTOOLSPACE;
334 }
335 HRESULT STDMETHODCALLTYPE SetBorderSpace(LPCBORDERWIDTHS)
336 {return S_OK;}
337 HRESULT STDMETHODCALLTYPE SetActiveObject(
338 IOleInPlaceActiveObject *pActiveObject, LPCOLESTR)
339 {
340 if (pActiveObject)
341 pActiveObject->AddRef();
342
343 m_window->m_oleInPlaceActiveObject = pActiveObject;
344 return S_OK;
345 }
346
347 //********************IOleInPlaceFrame************************
348
349 STDMETHOD(InsertMenus)(HMENU, LPOLEMENUGROUPWIDTHS){return S_OK;}
350 STDMETHOD(SetMenu)(HMENU, HOLEMENU, HWND){ return S_OK;}
351 STDMETHOD(RemoveMenus)(HMENU){return S_OK;}
352 STDMETHOD(SetStatusText)(LPCOLESTR){ return S_OK;}
353 HRESULT STDMETHODCALLTYPE EnableModeless(BOOL){return S_OK;}
354 HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG lpmsg, WORD)
355 {
356 // TODO: send an event with this id
357 if (m_window->m_oleInPlaceActiveObject.IsOk())
358 m_window->m_oleInPlaceActiveObject->TranslateAccelerator(lpmsg);
359 return S_FALSE;
360 }
361
362 //*******************IOleInPlaceSite**************************
363 HRESULT STDMETHODCALLTYPE CanInPlaceActivate(){return S_OK;}
364 HRESULT STDMETHODCALLTYPE OnInPlaceActivate()
365 { m_bInPlaceActive = true; return S_OK; }
366 HRESULT STDMETHODCALLTYPE OnUIActivate()
367 { m_bUIActive = true; return S_OK; }
368 HRESULT STDMETHODCALLTYPE GetWindowContext(IOleInPlaceFrame **ppFrame,
369 IOleInPlaceUIWindow **ppDoc,
370 LPRECT lprcPosRect,
371 LPRECT lprcClipRect,
372 LPOLEINPLACEFRAMEINFO lpFrameInfo)
373 {
374 if (ppFrame == NULL || ppDoc == NULL || lprcPosRect == NULL ||
375 lprcClipRect == NULL || lpFrameInfo == NULL)
376 {
377 if (ppFrame != NULL)
378 (*ppFrame) = NULL;
379 if (ppDoc != NULL)
380 (*ppDoc) = NULL;
381 return E_INVALIDARG;
382 }
383
384 HRESULT hr = QueryInterface(IID_IOleInPlaceFrame, (void **) ppFrame);
385 if (! SUCCEEDED(hr))
386 {
387 return E_UNEXPECTED;
388 }
389
390 hr = QueryInterface(IID_IOleInPlaceUIWindow, (void **) ppDoc);
391 if (! SUCCEEDED(hr))
392 {
393 (*ppFrame)->Release();
394 *ppFrame = NULL;
395 return E_UNEXPECTED;
396 }
397
398 RECT rect;
399 ::GetClientRect(m_hWndParent, &rect);
400 if (lprcPosRect)
401 {
402 lprcPosRect->left = lprcPosRect->top = 0;
403 lprcPosRect->right = rect.right;
404 lprcPosRect->bottom = rect.bottom;
405 }
406 if (lprcClipRect)
407 {
408 lprcClipRect->left = lprcClipRect->top = 0;
409 lprcClipRect->right = rect.right;
410 lprcClipRect->bottom = rect.bottom;
411 }
412
413 memset(lpFrameInfo, 0, sizeof(OLEINPLACEFRAMEINFO));
414 lpFrameInfo->cb = sizeof(OLEINPLACEFRAMEINFO);
415 lpFrameInfo->hwndFrame = m_hWndParent;
416
417 return S_OK;
418 }
419 HRESULT STDMETHODCALLTYPE Scroll(SIZE){return S_OK;}
420 HRESULT STDMETHODCALLTYPE OnUIDeactivate(BOOL)
421 { m_bUIActive = false; return S_OK; }
422 HRESULT STDMETHODCALLTYPE OnInPlaceDeactivate()
423 { m_bInPlaceActive = false; return S_OK; }
424 HRESULT STDMETHODCALLTYPE DiscardUndoState(){return S_OK;}
425 HRESULT STDMETHODCALLTYPE DeactivateAndUndo(){return S_OK; }
426 HRESULT STDMETHODCALLTYPE OnPosRectChange(LPCRECT lprcPosRect)
427 {
428 if (m_window->m_oleInPlaceObject.IsOk() && lprcPosRect)
429 {
430 //
431 // Result of several hours and days of bug hunting -
432 // this is called by an object when it wants to resize
433 // itself to something different then our parent window -
434 // don't let it :)
435 //
436// m_window->m_oleInPlaceObject->SetObjectRects(
437// lprcPosRect, lprcPosRect);
438 RECT rcClient;
439 ::GetClientRect(m_hWndParent, &rcClient);
440 m_window->m_oleInPlaceObject->SetObjectRects(
441 &rcClient, &rcClient);
442 }
443 return S_OK;
444 }
445 //*************************IOleInPlaceSiteEx***********************
446 HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(BOOL * pfNoRedraw, DWORD)
447 {
448#ifdef __WXWINCE__
449 IRunnableObject* runnable = NULL;
450 HRESULT hr = QueryInterface(
451 IID_IRunnableObject, (void**)(& runnable));
452 if (SUCCEEDED(hr))
453 {
454 runnable->LockRunning(TRUE, FALSE);
455 }
456#else
457 OleLockRunning(m_window->m_ActiveX, TRUE, FALSE);
458#endif
459 if (pfNoRedraw)
460 (*pfNoRedraw) = FALSE;
461 return S_OK;
462 }
463
464 HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(BOOL)
465 {
466#ifdef __WXWINCE__
467 IRunnableObject* runnable = NULL;
468 HRESULT hr = QueryInterface(
469 IID_IRunnableObject, (void**)(& runnable));
470 if (SUCCEEDED(hr))
471 {
472 runnable->LockRunning(FALSE, FALSE);
473 }
474#else
475 OleLockRunning(m_window->m_ActiveX, FALSE, FALSE);
476#endif
477 return S_OK;
478 }
479 STDMETHOD(RequestUIActivate)(){ return S_OK;}
480 //*************************IOleClientSite**************************
481 HRESULT STDMETHODCALLTYPE SaveObject(){return S_OK;}
482 const char *OleGetMonikerToStr(DWORD dwAssign)
483 {
484 switch (dwAssign)
485 {
486 case OLEGETMONIKER_ONLYIFTHERE : return "OLEGETMONIKER_ONLYIFTHERE";
487 case OLEGETMONIKER_FORCEASSIGN : return "OLEGETMONIKER_FORCEASSIGN";
488 case OLEGETMONIKER_UNASSIGN : return "OLEGETMONIKER_UNASSIGN";
489 case OLEGETMONIKER_TEMPFORUSER : return "OLEGETMONIKER_TEMPFORUSER";
490 default : return "Bad Enum";
491 }
492 }
493
494 const char *OleGetWhicMonikerStr(DWORD dwWhichMoniker)
495 {
496 switch(dwWhichMoniker)
497 {
498 case OLEWHICHMK_CONTAINER : return "OLEWHICHMK_CONTAINER";
499 case OLEWHICHMK_OBJREL : return "OLEWHICHMK_OBJREL";
500 case OLEWHICHMK_OBJFULL : return "OLEWHICHMK_OBJFULL";
501 default : return "Bad Enum";
502 }
503 }
504 STDMETHOD(GetMoniker)(DWORD, DWORD, IMoniker **){return E_FAIL;}
505 HRESULT STDMETHODCALLTYPE GetContainer(LPOLECONTAINER * ppContainer)
506 {
507 if (ppContainer == NULL)
508 return E_INVALIDARG;
509 HRESULT hr = QueryInterface(
510 IID_IOleContainer, (void**)(ppContainer));
511 wxASSERT(SUCCEEDED(hr));
512 return hr;
513 }
514 HRESULT STDMETHODCALLTYPE ShowObject()
515 {
516 if (m_window->m_oleObjectHWND)
517 ::ShowWindow(m_window->m_oleObjectHWND, SW_SHOW);
518 return S_OK;
519 }
520 STDMETHOD(OnShowWindow)(BOOL){return S_OK;}
521 STDMETHOD(RequestNewObjectLayout)(){return E_NOTIMPL;}
522 //********************IParseDisplayName***************************
523 HRESULT STDMETHODCALLTYPE ParseDisplayName(
524 IBindCtx *, LPOLESTR, ULONG *, IMoniker **){return E_NOTIMPL;}
525 //********************IOleContainer*******************************
526 STDMETHOD(EnumObjects)(DWORD, IEnumUnknown **){return E_NOTIMPL;}
527 HRESULT STDMETHODCALLTYPE LockContainer(BOOL){return S_OK;}
528 //********************IOleItemContainer***************************
529 HRESULT STDMETHODCALLTYPE
530 #if 0 // defined(__WXWINCE__) && __VISUALC__ < 1400
531 GetObject
532 #elif defined(_UNICODE)
533 GetObjectW
534 #else
535 GetObjectA
536 #endif
537 (LPOLESTR pszItem, DWORD, IBindCtx *, REFIID, void ** ppvObject)
538 {
539 if (pszItem == NULL || ppvObject == NULL)
540 return E_INVALIDARG;
541 *ppvObject = NULL;
542 return MK_E_NOOBJECT;
543 }
544 HRESULT STDMETHODCALLTYPE GetObjectStorage(
545 LPOLESTR pszItem, IBindCtx * , REFIID, void ** ppvStorage)
546 {
547 if (pszItem == NULL || ppvStorage == NULL)
548 return E_INVALIDARG;
549 *ppvStorage = NULL;
550 return MK_E_NOOBJECT;
551 }
552 HRESULT STDMETHODCALLTYPE IsRunning(LPOLESTR pszItem)
553 {
554 if (pszItem == NULL)
555 return E_INVALIDARG;
556 return MK_E_NOOBJECT;
557 }
558 //***********************IOleControlSite*****************************
559 HRESULT STDMETHODCALLTYPE OnControlInfoChanged()
560 {return S_OK;}
561 HRESULT STDMETHODCALLTYPE LockInPlaceActive(BOOL fLock)
562 {
563 m_bInPlaceLocked = (fLock) ? true : false;
564 return S_OK;
565 }
566 HRESULT STDMETHODCALLTYPE GetExtendedControl(IDispatch **)
567 {return E_NOTIMPL;}
568 HRESULT STDMETHODCALLTYPE TransformCoords(
569 POINTL * pPtlHimetric, POINTF * pPtfContainer, DWORD)
570 {
571 if (pPtlHimetric == NULL || pPtfContainer == NULL)
572 return E_INVALIDARG;
573 return E_NOTIMPL;
574 }
575 HRESULT STDMETHODCALLTYPE TranslateAccelerator(LPMSG, DWORD)
576 {return E_NOTIMPL;}
577 HRESULT STDMETHODCALLTYPE OnFocus(BOOL){return S_OK;}
578 HRESULT STDMETHODCALLTYPE ShowPropertyFrame(){return E_NOTIMPL;}
579 //**************************IOleCommandTarget***********************
580 HRESULT STDMETHODCALLTYPE QueryStatus(const GUID *, ULONG cCmds,
581 OLECMD prgCmds[], OLECMDTEXT *)
582 {
583 if (prgCmds == NULL) return E_INVALIDARG;
584 for (ULONG nCmd = 0; nCmd < cCmds; nCmd++)
585 {
586 // unsupported by default
587 prgCmds[nCmd].cmdf = 0;
588 }
589 return OLECMDERR_E_UNKNOWNGROUP;
590 }
591
592 HRESULT STDMETHODCALLTYPE Exec(const GUID *, DWORD,
593 DWORD, VARIANTARG *, VARIANTARG *)
594 {return OLECMDERR_E_NOTSUPPORTED;}
595
596 //**********************IAdviseSink************************************
597 void STDMETHODCALLTYPE OnDataChange(FORMATETC *, STGMEDIUM *) {}
598 void STDMETHODCALLTYPE OnViewChange(DWORD, LONG) {}
599 void STDMETHODCALLTYPE OnRename(IMoniker *){}
600 void STDMETHODCALLTYPE OnSave(){}
601 void STDMETHODCALLTYPE OnClose(){}
602
603 //**********************IOleDocumentSite***************************
604 HRESULT STDMETHODCALLTYPE ActivateMe(
605 IOleDocumentView __RPC_FAR *pViewToActivate)
606 {
607 wxAutoIOleInPlaceSite inPlaceSite(
608 IID_IOleInPlaceSite, (IDispatch *) this);
609 if (!inPlaceSite.IsOk())
610 return E_FAIL;
611
612 if (pViewToActivate)
613 {
614 m_window->m_docView = pViewToActivate;
615 m_window->m_docView->SetInPlaceSite(inPlaceSite);
616 }
617 else
618 {
619 wxAutoIOleDocument oleDoc(
620 IID_IOleDocument, m_window->m_oleObject);
621 if (! oleDoc.IsOk())
622 return E_FAIL;
623
624 HRESULT hr = oleDoc->CreateView(inPlaceSite, NULL,
625 0, m_window->m_docView.GetRef());
626 if (hr != S_OK)
627 return E_FAIL;
628
629 m_window->m_docView->SetInPlaceSite(inPlaceSite);
630 }
631
632 m_window->m_docView->UIActivate(TRUE);
633 return S_OK;
634 }
635
636
637protected:
638 wxActiveXContainer * m_window;
639
640 HDC m_hDCBuffer;
641 HWND m_hWndParent;
642
643 bool m_bSupportsWindowlessActivation;
644 bool m_bInPlaceLocked;
645 bool m_bInPlaceActive;
646 bool m_bUIActive;
647 bool m_bWindowless;
648
649 LCID m_nAmbientLocale;
650 COLORREF m_clrAmbientForeColor;
651 COLORREF m_clrAmbientBackColor;
652 bool m_bAmbientShowHatching;
653 bool m_bAmbientShowGrabHandles;
654 bool m_bAmbientAppearance;
655};
656
657DEFINE_OLE_TABLE(FrameSite)
658 OLE_INTERFACE(IID_IUnknown, IOleClientSite)
659 OLE_IINTERFACE(IOleClientSite)
660 OLE_INTERFACE(IID_IOleWindow, IOleInPlaceSite)
661 OLE_IINTERFACE(IOleInPlaceSite)
662 OLE_IINTERFACE(IOleInPlaceSiteEx)
663 OLE_IINTERFACE(IOleInPlaceUIWindow)
664 OLE_IINTERFACE(IOleInPlaceFrame)
665 OLE_IINTERFACE(IParseDisplayName)
666 OLE_IINTERFACE(IOleContainer)
667 OLE_IINTERFACE(IOleItemContainer)
668 OLE_IINTERFACE(IDispatch)
669 OLE_IINTERFACE(IOleCommandTarget)
670 OLE_IINTERFACE(IOleDocumentSite)
671 OLE_IINTERFACE(IAdviseSink)
672 OLE_IINTERFACE(IOleControlSite)
673END_OLE_TABLE
674
675
676//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
677//
678// wxActiveXEvents
679//
680// Handles and sends activex events received from the ActiveX control
681// to the appropriate wxEvtHandler
682//
683//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
684class wxActiveXEvents : public IDispatch
685{
686private:
687 DECLARE_OLE_UNKNOWN(wxActiveXEvents);
688
689
690 wxActiveXContainer *m_activeX;
691 IID m_customId;
692 bool m_haveCustomId;
693
694 friend bool wxActiveXEventsInterface(wxActiveXEvents *self, REFIID iid, void **_interface, const char *&desc);
695
696public:
697
698 // a pointer to this static variable is used as an 'invalid_entry_marker'
699 // wxVariants containing a void* to this variables are 'empty' in the sense
700 // that the actual ActiveX OLE parameter has not been converted and inserted
701 // into m_params.
702 static wxVariant ms_invalidEntryMarker;
703
704 wxActiveXEvents(wxActiveXContainer *ax) : m_activeX(ax), m_haveCustomId(false) {}
705 wxActiveXEvents(wxActiveXContainer *ax, REFIID iid) : m_activeX(ax), m_customId(iid), m_haveCustomId(true) {}
706 virtual ~wxActiveXEvents()
707 {
708 }
709
710 // IDispatch
711 STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR**, unsigned int, LCID, DISPID*)
712 {
713 return E_NOTIMPL;
714 }
715
716 STDMETHODIMP GetTypeInfo(unsigned int, LCID, ITypeInfo**)
717 {
718 return E_NOTIMPL;
719 }
720
721 STDMETHODIMP GetTypeInfoCount(unsigned int*)
722 {
723 return E_NOTIMPL;
724 }
725
726
727 STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid,
728 LCID lcid,
729 WORD wFlags, DISPPARAMS * pDispParams,
730 VARIANT * pVarResult, EXCEPINFO * pExcepInfo,
731 unsigned int * puArgErr)
732 {
733 if (wFlags & (DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF))
734 return E_NOTIMPL;
735
736 wxASSERT(m_activeX);
737
738 // ActiveX Event
739
740 // Dispatch Event
741 wxActiveXEvent event;
742 event.SetEventType(wxEVT_ACTIVEX);
743 // Create an empty list of Variants
744 // Note that the event parameters use lazy evaluation
745 // They are not actually created until wxActiveXEvent::operator[] is called
746 event.m_params.NullList();
747 event.m_dispid = dispIdMember;
748
749 // save the native (MSW) event parameters for event handlers that need to access them
750 // this can be done on the stack since wxActiveXEvent is also allocated on the stack
751 wxActiveXEventNativeMSW eventParameters(dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
752 event.SetClientData(&eventParameters);
753
754 // The event parameters are not copied to event.m_params until they are actually
755 // referenced in wxActiveXEvent::operator[]
756 // This increases performance and avoids error messages and/or crashes
757 // when the event has parameters that are not (yet or never) supported
758 // by wxConvertOleToVariant
759
760 // process the events from the activex method
761 m_activeX->ProcessEvent(event);
762 for (DWORD i = 0; i < pDispParams->cArgs; i++)
763 {
764 size_t params_index = pDispParams->cArgs - i - 1;
765 if (params_index < event.m_params.GetCount()) {
766 wxVariant &vx = event.m_params[params_index];
767 // copy the result back to pDispParams only if the event has been accessed
768 // i.e. if vx != ms_invalidEntryMarker
769 if (!vx.IsType(wxActiveXEvents::ms_invalidEntryMarker.GetType()) || vx!=ms_invalidEntryMarker) {
770 VARIANTARG& va = pDispParams->rgvarg[i];
771 wxConvertVariantToOle(vx, va);
772 }
773 }
774 }
775
776 if(event.GetSkipped())
777 return DISP_E_MEMBERNOTFOUND;
778
779 return S_OK;
780 }
781};
782
783namespace
784{
785// just a unique global variable
786const int invalid_entry_marker = 0;
787}
788
789wxVariant wxActiveXEvents::ms_invalidEntryMarker((void*)&invalid_entry_marker);
790
791size_t wxActiveXEvent::ParamCount() const
792{
793 wxActiveXEventNativeMSW *native=GetNativeParameters();
794 // 'native' will always be != if the event has been created
795 // for an actual active X event.
796 // But it may be zero if the event has been created by wx program code.
797 if (native)
798 return native->pDispParams ? native->pDispParams->cArgs : 0;
799
800 return m_params.GetCount();
801}
802
803wxVariant &wxActiveXEvent::operator [](size_t idx)
804{
805 wxASSERT(idx < ParamCount());
806 wxActiveXEventNativeMSW *native=GetNativeParameters();
807 // 'native' will always be != if the event has been created
808 // for an actual active X event.
809 // But it may be zero if the event has been created by wx program code.
810 if (native)
811 {
812 while ( m_params.GetCount()<=idx )
813 {
814 m_params.Append(wxActiveXEvents::ms_invalidEntryMarker);
815 }
816
817 wxVariant& vx = m_params[idx];
818 if ( vx.IsType(wxActiveXEvents::ms_invalidEntryMarker.GetType()) &&
819 vx == wxActiveXEvents::ms_invalidEntryMarker)
820 {
821 // copy the _real_ parameter into this one
822 // NOTE: m_params stores the parameters in *reverse* order.
823 // Whyever, but this was the case in the original implementation of
824 // wxActiveXEvents::Invoke
825 // Keep this convention.
826 VARIANTARG& va = native->pDispParams->rgvarg[ native->pDispParams->cArgs - idx - 1 ];
827 wxConvertOleToVariant(va, vx);
828 }
829 return vx;
830 }
831 return m_params[idx];
832}
833
834bool wxActiveXEventsInterface(wxActiveXEvents *self, REFIID iid, void **_interface, const char *&desc)
835{
836 if (self->m_haveCustomId && IsEqualIID(iid, self->m_customId))
837 {
838 *_interface = (IUnknown *) (IDispatch *) self;
839 desc = "Custom Dispatch Interface";
840 return true;
841 }
842
843 return false;
844}
845
846DEFINE_OLE_TABLE(wxActiveXEvents)
847 OLE_IINTERFACE(IUnknown)
848 OLE_INTERFACE(IID_IDispatch, IDispatch)
849 OLE_INTERFACE_CUSTOM(wxActiveXEventsInterface)
850END_OLE_TABLE
851
852//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
853//
854// wxActiveXContainer
855//
856//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
857
858//---------------------------------------------------------------------------
859// wxActiveXContainer Constructor
860//
861// Initializes members and creates the native ActiveX container
862//---------------------------------------------------------------------------
863wxActiveXContainer::wxActiveXContainer(wxWindow * parent,
864 REFIID iid, IUnknown* pUnk)
865 : m_realparent(parent)
866{
867 m_bAmbientUserMode = true;
868 m_docAdviseCookie = 0;
869 CreateActiveX(iid, pUnk);
870}
871
872//---------------------------------------------------------------------------
873// wxActiveXContainer Destructor
874//
875// Destroys members (the FrameSite et al. are destroyed implicitly
876// through COM ref counting)
877//---------------------------------------------------------------------------
878wxActiveXContainer::~wxActiveXContainer()
879{
880 // disconnect connection points
881 if (m_oleInPlaceObject.IsOk())
882 {
883 m_oleInPlaceObject->InPlaceDeactivate();
884 m_oleInPlaceObject->UIDeactivate();
885 }
886
887 if (m_oleObject.IsOk())
888 {
889 if (m_docAdviseCookie != 0)
890 m_oleObject->Unadvise(m_docAdviseCookie);
891
892 m_oleObject->DoVerb(
893 OLEIVERB_HIDE, NULL, m_clientSite, 0, (HWND) GetHWND(), NULL);
894 m_oleObject->Close(OLECLOSE_NOSAVE);
895 m_oleObject->SetClientSite(NULL);
896 }
897
898 // m_clientSite uses m_frameSite so destroy it first
899 m_clientSite.Free();
900 delete m_frameSite;
901
902 // our window doesn't belong to us, don't destroy it
903 m_hWnd = NULL;
904}
905
906// VZ: we might want to really report an error instead of just asserting here
907#if wxDEBUG_LEVEL
908 #define CHECK_HR(hr) \
909 wxASSERT_LEVEL_2_MSG( SUCCEEDED(hr), \
910 wxString::Format("HRESULT = %X", (unsigned)(hr)) )
911#else
912 #define CHECK_HR(hr) wxUnusedVar(hr)
913#endif
914
915//---------------------------------------------------------------------------
916// wxActiveXContainer::CreateActiveX
917//
918// Actually creates the ActiveX container through the FrameSite
919// and sets up ActiveX events
920//
921// TODO: Document this more
922//---------------------------------------------------------------------------
923void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
924{
925 HRESULT hret;
926 hret = m_ActiveX.QueryInterface(iid, pUnk);
927 CHECK_HR(hret);
928
929 // FrameSite
930 m_frameSite = new FrameSite(m_realparent, this);
931 // oleClientSite
932 hret = m_clientSite.QueryInterface(
933 IID_IOleClientSite, (IDispatch *) m_frameSite);
934 CHECK_HR(hret);
935 // adviseSink
936 wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite);
937 wxASSERT(adviseSink.IsOk());
938
939 // Get Dispatch interface
940 hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX);
941 CHECK_HR(hret);
942
943 //
944 // SETUP TYPEINFO AND ACTIVEX EVENTS
945 //
946
947 // get type info via class info
948 wxAutoIProvideClassInfo classInfo(IID_IProvideClassInfo, m_ActiveX);
949 wxASSERT(classInfo.IsOk());
950
951 // type info
952 wxAutoITypeInfo typeInfo;
953 hret = classInfo->GetClassInfo(typeInfo.GetRef());
954 CHECK_HR(hret);
955 wxASSERT(typeInfo.IsOk());
956
957 // TYPEATTR
958 TYPEATTR *ta = NULL;
959 hret = typeInfo->GetTypeAttr(&ta);
960 CHECK_HR(hret);
961
962 // this should be a TKIND_COCLASS
963 wxASSERT(ta->typekind == TKIND_COCLASS);
964
965 // iterate contained interfaces
966 for (int i = 0; i < ta->cImplTypes; i++)
967 {
968 HREFTYPE rt = 0;
969
970 // get dispatch type info handle
971 hret = typeInfo->GetRefTypeOfImplType(i, &rt);
972 if (! SUCCEEDED(hret))
973 continue;
974
975 // get dispatch type info interface
976 wxAutoITypeInfo ti;
977 hret = typeInfo->GetRefTypeInfo(rt, ti.GetRef());
978 if (! ti.IsOk())
979 continue;
980
981 CHECK_HR(hret);
982
983 // check if default event sink
984 bool defEventSink = false;
985 int impTypeFlags = 0;
986 typeInfo->GetImplTypeFlags(i, &impTypeFlags);
987
988 if (impTypeFlags & IMPLTYPEFLAG_FDEFAULT)
989 {
990 if (impTypeFlags & IMPLTYPEFLAG_FSOURCE)
991 {
992 // WXOLE_TRACEOUT("Default Event Sink");
993 defEventSink = true;
994 if (impTypeFlags & IMPLTYPEFLAG_FDEFAULTVTABLE)
995 {
996 // WXOLE_TRACEOUT("*ERROR* - Default Event Sink is via vTable");
997 defEventSink = false;
998 wxFAIL_MSG(wxT("Default event sink is in vtable!"));
999 }
1000 }
1001 }
1002
1003
1004 // wxAutoOleInterface<> assumes a ref has already been added
1005 // TYPEATTR
1006 TYPEATTR *ta = NULL;
1007 hret = ti->GetTypeAttr(&ta);
1008 CHECK_HR(hret);
1009
1010 if (ta->typekind == TKIND_DISPATCH)
1011 {
1012 // WXOLE_TRACEOUT("GUID = " << GetIIDName(ta->guid).c_str());
1013 if (defEventSink)
1014 {
1015 wxAutoIConnectionPoint cp;
1016 DWORD adviseCookie = 0;
1017
1018 wxAutoIConnectionPointContainer cpContainer(IID_IConnectionPointContainer, m_ActiveX);
1019 wxASSERT( cpContainer.IsOk());
1020
1021 HRESULT hret =
1022 cpContainer->FindConnectionPoint(ta->guid, cp.GetRef());
1023
1024 // Notice that the return value of CONNECT_E_NOCONNECTION is
1025 // expected if the interface doesn't support connection points.
1026 if ( hret != CONNECT_E_NOCONNECTION )
1027 {
1028 CHECK_HR(hret);
1029 }
1030
1031 if ( cp )
1032 {
1033 wxActiveXEvents * const
1034 events = new wxActiveXEvents(this, ta->guid);
1035 hret = cp->Advise(events, &adviseCookie);
1036
1037 // We don't need this object any more and cp will keep a
1038 // reference to it if it needs it, i.e. if Advise()
1039 // succeeded.
1040 events->Release();
1041
1042 CHECK_HR(hret);
1043 }
1044 }
1045 }
1046
1047 ti->ReleaseTypeAttr(ta);
1048 }
1049
1050 // free
1051 typeInfo->ReleaseTypeAttr(ta);
1052
1053 //
1054 // END
1055 //
1056
1057 // Get IOleObject interface
1058 hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX);
1059 CHECK_HR(hret);
1060
1061 // get IViewObject Interface
1062 hret = m_viewObject.QueryInterface(IID_IViewObject, m_ActiveX);
1063 CHECK_HR(hret);
1064
1065 // document advise
1066 m_docAdviseCookie = 0;
1067 hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie);
1068 CHECK_HR(hret);
1069
1070 // TODO:Needed?
1071// hret = m_viewObject->SetAdvise(DVASPECT_CONTENT, 0, adviseSink);
1072 m_oleObject->SetHostNames(L"wxActiveXContainer", NULL);
1073 OleSetContainedObject(m_oleObject, TRUE);
1074 OleRun(m_oleObject);
1075
1076
1077 // Get IOleInPlaceObject interface
1078 hret = m_oleInPlaceObject.QueryInterface(
1079 IID_IOleInPlaceObject, m_ActiveX);
1080 CHECK_HR(hret);
1081
1082 // status
1083 DWORD dwMiscStatus;
1084 m_oleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
1085 CHECK_HR(hret);
1086
1087 // set client site first ?
1088 if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)
1089 m_oleObject->SetClientSite(m_clientSite);
1090
1091
1092 // stream init
1093 wxAutoIPersistStreamInit
1094 pPersistStreamInit(IID_IPersistStreamInit, m_oleObject);
1095
1096 if (pPersistStreamInit.IsOk())
1097 {
1098 hret = pPersistStreamInit->InitNew();
1099 CHECK_HR(hret);
1100 }
1101
1102 if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
1103 m_oleObject->SetClientSite(m_clientSite);
1104
1105
1106 m_oleObjectHWND = 0;
1107
1108 if (m_oleInPlaceObject.IsOk())
1109 {
1110 hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
1111 if (SUCCEEDED(hret))
1112 ::SetActiveWindow(m_oleObjectHWND);
1113 }
1114
1115
1116 if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME))
1117 {
1118 RECT posRect;
1119 wxCopyRectToRECT(m_realparent->GetClientSize(), posRect);
1120
1121 if (posRect.right > 0 && posRect.bottom > 0 &&
1122 m_oleInPlaceObject.IsOk())
1123 {
1124 m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
1125 }
1126
1127 hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL,
1128 m_clientSite, 0, (HWND)m_realparent->GetHWND(), &posRect);
1129 CHECK_HR(hret);
1130
1131 hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0,
1132 (HWND)m_realparent->GetHWND(), &posRect);
1133 CHECK_HR(hret);
1134 }
1135
1136 if (! m_oleObjectHWND && m_oleInPlaceObject.IsOk())
1137 {
1138 hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
1139 CHECK_HR(hret);
1140 }
1141
1142 if (m_oleObjectHWND)
1143 {
1144 ::SetActiveWindow(m_oleObjectHWND);
1145 ::ShowWindow(m_oleObjectHWND, SW_SHOW);
1146
1147 this->AssociateHandle(m_oleObjectHWND);
1148 this->Reparent(m_realparent);
1149
1150 wxWindow* pWnd = m_realparent;
1151 int id = m_realparent->GetId();
1152
1153 pWnd->Connect(id, wxEVT_SIZE,
1154 wxSizeEventHandler(wxActiveXContainer::OnSize), 0, this);
1155// this->Connect(GetId(), wxEVT_PAINT,
1156// wxPaintEventHandler(wxActiveXContainer::OnPaint), 0, this);
1157 pWnd->Connect(id, wxEVT_SET_FOCUS,
1158 wxFocusEventHandler(wxActiveXContainer::OnSetFocus), 0, this);
1159 pWnd->Connect(id, wxEVT_KILL_FOCUS,
1160 wxFocusEventHandler(wxActiveXContainer::OnKillFocus), 0, this);
1161 }
1162}
1163
1164//---------------------------------------------------------------------------
1165// wxActiveXContainer::OnSize
1166//
1167// Called when the parent is resized - we need to do this to actually
1168// move the ActiveX control to where the parent is
1169//---------------------------------------------------------------------------
1170void wxActiveXContainer::OnSize(wxSizeEvent& event)
1171{
1172 int w, h;
1173 GetParent()->GetClientSize(&w, &h);
1174
1175 RECT posRect;
1176 posRect.left = 0;
1177 posRect.top = 0;
1178 posRect.right = w;
1179 posRect.bottom = h;
1180
1181 if (w <= 0 && h <= 0)
1182 return;
1183
1184 // extents are in HIMETRIC units
1185 if (m_oleObject.IsOk())
1186 {
1187 m_oleObject->DoVerb(OLEIVERB_HIDE, 0, m_clientSite, 0,
1188 (HWND)m_realparent->GetHWND(), &posRect);
1189
1190 SIZEL sz = {w, h};
1191 PixelsToHimetric(sz);
1192
1193 SIZEL sz2;
1194
1195 m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2);
1196 if (sz2.cx != sz.cx || sz.cy != sz2.cy)
1197 m_oleObject->SetExtent(DVASPECT_CONTENT, &sz);
1198
1199 m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0,
1200 (HWND)m_realparent->GetHWND(), &posRect);
1201 }
1202
1203 if (m_oleInPlaceObject.IsOk())
1204 m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
1205
1206 event.Skip();
1207}
1208
1209//---------------------------------------------------------------------------
1210// wxActiveXContainer::OnPaint
1211//
1212// Called when the parent is resized - repaints the ActiveX control
1213//---------------------------------------------------------------------------
1214void wxActiveXContainer::OnPaint(wxPaintEvent& WXUNUSED(event))
1215{
1216 wxPaintDC dc(this);
1217 // Draw only when control is windowless or deactivated
1218 if (m_viewObject)
1219 {
1220 int w, h;
1221 GetParent()->GetSize(&w, &h);
1222 RECT posRect;
1223 posRect.left = 0;
1224 posRect.top = 0;
1225 posRect.right = w;
1226 posRect.bottom = h;
1227
1228#if !(defined(_WIN32_WCE) && _WIN32_WCE < 400)
1229 ::RedrawWindow(m_oleObjectHWND, NULL, NULL, RDW_INTERNALPAINT);
1230#else
1231 ::InvalidateRect(m_oleObjectHWND, NULL, false);
1232#endif
1233 RECTL *prcBounds = (RECTL *) &posRect;
1234 wxMSWDCImpl *msw = wxDynamicCast( dc.GetImpl() , wxMSWDCImpl );
1235 m_viewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL,
1236 (HDC)msw->GetHDC(), prcBounds, NULL, NULL, 0);
1237 }
1238}
1239
1240//---------------------------------------------------------------------------
1241// wxActiveXContainer::OnSetFocus
1242//
1243// Called when the focus is set on the parent - activates the activex control
1244//---------------------------------------------------------------------------
1245void wxActiveXContainer::OnSetFocus(wxFocusEvent& event)
1246{
1247 if (m_oleInPlaceActiveObject.IsOk())
1248 m_oleInPlaceActiveObject->OnFrameWindowActivate(TRUE);
1249
1250 event.Skip();
1251}
1252
1253//---------------------------------------------------------------------------
1254// wxActiveXContainer::OnKillFocus
1255//
1256// Called when the focus is killed on the parent -
1257// deactivates the activex control
1258//---------------------------------------------------------------------------
1259void wxActiveXContainer::OnKillFocus(wxFocusEvent& event)
1260{
1261 if (m_oleInPlaceActiveObject.IsOk())
1262 m_oleInPlaceActiveObject->OnFrameWindowActivate(FALSE);
1263
1264 event.Skip();
1265}
1266
1267#endif // wxUSE_ACTIVEX