]> git.saurik.com Git - wxWidgets.git/blame - src/msw/ole/activex.cpp
added (wxMSW-only) wxToolTip::SetMaxWidth() and improve its default behaviour (#2817)
[wxWidgets.git] / src / msw / ole / activex.cpp
CommitLineData
bf354396 1/////////////////////////////////////////////////////////////////////////////
5d484919 2// Name: src/msw/ole/activex.cpp
bf354396
VZ
3// Purpose: wxActiveXContainer implementation
4// Author: Ryan Norton <wxprojects@comcast.net>, Lindsay Mathieson <???>
c493691d 5// Modified by:
bf354396
VZ
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
c493691d
WS
12// ============================================================================
13// declarations
14// ============================================================================
bf354396 15
c493691d
WS
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
bf354396 19
c493691d 20#include "wx/wxprec.h"
bf354396 21
c493691d
WS
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
bf354396 25
a1f48575
VZ
26#if wxUSE_ACTIVEX
27
ed4b0fdc
WS
28#ifndef WX_PRECOMP
29 #include "wx/dcclient.h"
18680f86 30 #include "wx/math.h"
ed4b0fdc
WS
31#endif
32
363e2dc0
PC
33#include "wx/msw/dc.h"
34
557002cf 35#include "wx/msw/ole/activex.h"
403dd8db
VZ
36#include "wx/msw/private.h" // for wxCopyRectToRECT
37
557002cf
VZ
38// autointerfaces that we only use here
39WX_DECLARE_AUTOOLE(wxAutoIOleInPlaceSite, IOleInPlaceSite)
40WX_DECLARE_AUTOOLE(wxAutoIOleDocument, IOleDocument)
41WX_DECLARE_AUTOOLE(wxAutoIPersistStreamInit, IPersistStreamInit)
42WX_DECLARE_AUTOOLE(wxAutoIAdviseSink, IAdviseSink)
43WX_DECLARE_AUTOOLE(wxAutoIProvideClassInfo, IProvideClassInfo)
44WX_DECLARE_AUTOOLE(wxAutoITypeInfo, ITypeInfo)
45WX_DECLARE_AUTOOLE(wxAutoIConnectionPoint, IConnectionPoint)
46WX_DECLARE_AUTOOLE(wxAutoIConnectionPointContainer, IConnectionPointContainer)
47
3c778901 48wxDEFINE_EVENT( wxEVT_ACTIVEX, wxActiveXEvent )
557002cf
VZ
49
50// Ole class helpers (sort of MFC-like) from wxActiveX
bf354396
VZ
51#define DECLARE_OLE_UNKNOWN(cls)\
52 private:\
53 class TAutoInitInt\
54 {\
55 public:\
56 LONG l;\
57 TAutoInitInt() : l(0) {}\
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;\
f74fd79b 76 }\
bf354396
VZ
77 const char *desc = NULL;\
78 cls::_GetInterface(this, iid, ppvObject, desc);\
79 if (! *ppvObject)\
80 {\
81 return E_NOINTERFACE;\
f74fd79b 82 }\
bf354396
VZ
83 ((IUnknown * )(*ppvObject))->AddRef();\
84 return S_OK;\
f74fd79b 85 }\
bf354396
VZ
86 ULONG STDMETHODCALLTYPE cls::AddRef()\
87 {\
88 InterlockedIncrement(&refCount.l);\
89 return refCount.l;\
f74fd79b 90 }\
bf354396
VZ
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;\
f74fd79b 100 }\
bf354396
VZ
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;\
f74fd79b 110 }\
bf354396
VZ
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
557002cf
VZ
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
bf354396 186
557002cf
VZ
187//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
188//
189// FrameSite
190//
191// Handles the actual wxActiveX container implementation
192//
193//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bf354396
VZ
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;
557002cf 269
bf354396
VZ
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;
557002cf 304
bf354396
VZ
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.Ok())
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;
f74fd79b 388 }
bf354396
VZ
389
390 hr = QueryInterface(IID_IOleInPlaceUIWindow, (void **) ppDoc);
391 if (! SUCCEEDED(hr))
392 {
393 (*ppFrame)->Release();
394 *ppFrame = NULL;
395 return E_UNEXPECTED;
f74fd79b 396 }
bf354396
VZ
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;
f74fd79b 405 }
bf354396
VZ
406 if (lprcClipRect)
407 {
408 lprcClipRect->left = lprcClipRect->top = 0;
409 lprcClipRect->right = rect.right;
410 lprcClipRect->bottom = rect.bottom;
f74fd79b 411 }
bf354396
VZ
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.Ok() && lprcPosRect)
429 {
557002cf
VZ
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);
bf354396 440 m_window->m_oleInPlaceObject->SetObjectRects(
557002cf 441 &rcClient, &rcClient);
bf354396
VZ
442 }
443 return S_OK;
444 }
445 //*************************IOleInPlaceSiteEx***********************
446 HRESULT STDMETHODCALLTYPE OnInPlaceActivateEx(BOOL * pfNoRedraw, DWORD)
447 {
a5fc9a1c
JS
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
bf354396 457 OleLockRunning(m_window->m_ActiveX, TRUE, FALSE);
a5fc9a1c 458#endif
bf354396
VZ
459 if (pfNoRedraw)
460 (*pfNoRedraw) = FALSE;
461 return S_OK;
462 }
463
464 HRESULT STDMETHODCALLTYPE OnInPlaceDeactivateEx(BOOL)
465 {
a5fc9a1c
JS
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
bf354396 475 OleLockRunning(m_window->m_ActiveX, FALSE, FALSE);
a5fc9a1c 476#endif
bf354396
VZ
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";
f74fd79b
VZ
491 }
492 }
bf354396
VZ
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";
f74fd79b
VZ
502 }
503 }
bf354396
VZ
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
ff759b6a 530 #if 0 // defined(__WXWINCE__) && __VISUALC__ < 1400
7dab17dd
WS
531 GetObject
532 #elif defined(_UNICODE)
bf354396
VZ
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.Ok())
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.Ok())
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);
f74fd79b 630 }
bf354396
VZ
631
632 m_window->m_docView->UIActivate(TRUE);
633 return S_OK;
f74fd79b 634 }
bf354396
VZ
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)
f74fd79b 673END_OLE_TABLE
557002cf
VZ
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 wxActiveXEvents(wxActiveXContainer *ax) : m_activeX(ax), m_haveCustomId(false) {}
f3a69d1d 698 wxActiveXEvents(wxActiveXContainer *ax, REFIID iid) : m_activeX(ax), m_customId(iid), m_haveCustomId(true) {}
557002cf
VZ
699 virtual ~wxActiveXEvents()
700 {
701 }
702
703 // IDispatch
704 STDMETHODIMP GetIDsOfNames(REFIID, OLECHAR**, unsigned int, LCID, DISPID*)
705 {
706 return E_NOTIMPL;
707 }
708
709 STDMETHODIMP GetTypeInfo(unsigned int, LCID, ITypeInfo**)
710 {
711 return E_NOTIMPL;
712 }
713
714 STDMETHODIMP GetTypeInfoCount(unsigned int*)
715 {
716 return E_NOTIMPL;
717 }
bf354396
VZ
718
719
557002cf
VZ
720 STDMETHODIMP Invoke(DISPID dispIdMember, REFIID WXUNUSED(riid),
721 LCID WXUNUSED(lcid),
722 WORD wFlags, DISPPARAMS * pDispParams,
723 VARIANT * WXUNUSED(pVarResult), EXCEPINFO * WXUNUSED(pExcepInfo),
724 unsigned int * WXUNUSED(puArgErr))
725 {
726 if (wFlags & (DISPATCH_PROPERTYGET | DISPATCH_PROPERTYPUT | DISPATCH_PROPERTYPUTREF))
727 return E_NOTIMPL;
728
729 wxASSERT(m_activeX);
730
731 // ActiveX Event
732
733 // Dispatch Event
734 wxActiveXEvent event;
735 event.SetEventType(wxEVT_ACTIVEX);
736 event.m_params.NullList();
737 event.m_dispid = dispIdMember;
738
739 // arguments
740 if (pDispParams)
741 {
742 for (DWORD i = pDispParams->cArgs; i > 0; i--)
743 {
744 VARIANTARG& va = pDispParams->rgvarg[i-1];
745 wxVariant vx;
746
747// vx.SetName(px.name);
748 wxConvertOleToVariant(va, vx);
749 event.m_params.Append(vx);
750 }
751 }
752
753 // process the events from the activex method
754 m_activeX->ProcessEvent(event);
755 for (DWORD i = 0; i < pDispParams->cArgs; i++)
756 {
757 VARIANTARG& va = pDispParams->rgvarg[i];
758 wxVariant& vx =
759 event.m_params[pDispParams->cArgs - i - 1];
760 wxConvertVariantToOle(vx, va);
761 }
762
763 if(event.GetSkipped())
764 return DISP_E_MEMBERNOTFOUND;
765
766 return S_OK;
767 }
768};
769
770bool wxActiveXEventsInterface(wxActiveXEvents *self, REFIID iid, void **_interface, const char *&desc)
771{
772 if (self->m_haveCustomId && IsEqualIID(iid, self->m_customId))
773 {
774// WXOLE_TRACE("Found Custom Dispatch Interface");
775 *_interface = (IUnknown *) (IDispatch *) self;
776 desc = "Custom Dispatch Interface";
777 return true;
f74fd79b 778 }
557002cf
VZ
779
780 return false;
781}
782
783DEFINE_OLE_TABLE(wxActiveXEvents)
784 OLE_IINTERFACE(IUnknown)
785 OLE_INTERFACE(IID_IDispatch, IDispatch)
786 OLE_INTERFACE_CUSTOM(wxActiveXEventsInterface)
f74fd79b 787END_OLE_TABLE
557002cf
VZ
788
789//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
790//
791// wxActiveXContainer
792//
793//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
794
795//---------------------------------------------------------------------------
796// wxActiveXContainer Constructor
797//
798// Initializes members and creates the native ActiveX container
799//---------------------------------------------------------------------------
800wxActiveXContainer::wxActiveXContainer(wxWindow * parent,
801 REFIID iid, IUnknown* pUnk)
bf354396
VZ
802 : m_realparent(parent)
803{
804 m_bAmbientUserMode = true;
805 m_docAdviseCookie = 0;
806 CreateActiveX(iid, pUnk);
807}
808
557002cf
VZ
809//---------------------------------------------------------------------------
810// wxActiveXContainer Destructor
811//
812// Destroys members (the FrameSite et al. are destroyed implicitly
813// through COM ref counting)
814//---------------------------------------------------------------------------
bf354396
VZ
815wxActiveXContainer::~wxActiveXContainer()
816{
817 // disconnect connection points
818 if (m_oleInPlaceObject.Ok())
819 {
820 m_oleInPlaceObject->InPlaceDeactivate();
821 m_oleInPlaceObject->UIDeactivate();
822 }
823
824 if (m_oleObject.Ok())
825 {
826 if (m_docAdviseCookie != 0)
827 m_oleObject->Unadvise(m_docAdviseCookie);
828
829 m_oleObject->DoVerb(
830 OLEIVERB_HIDE, NULL, m_clientSite, 0, (HWND) GetHWND(), NULL);
831 m_oleObject->Close(OLECLOSE_NOSAVE);
832 m_oleObject->SetClientSite(NULL);
833 }
9b53796d
VZ
834
835 // m_clientSite uses m_frameSite so destroy it first
836 m_clientSite.Free();
837 delete m_frameSite;
07a971ee
VZ
838
839 // our window doesn't belong to us, don't destroy it
840 m_hWnd = NULL;
bf354396
VZ
841}
842
f1430ac7
VZ
843// VZ: we might want to really report an error instead of just asserting here
844#ifdef __WXDEBUG__
845 #define CHECK_HR(hr) \
846 wxASSERT_MSG( SUCCEEDED(hr), \
847 wxString::Format("HRESULT = %X", (unsigned)(hr)) )
848#else
849 #define CHECK_HR(hr) wxUnusedVar(hr)
850#endif
851
557002cf
VZ
852//---------------------------------------------------------------------------
853// wxActiveXContainer::CreateActiveX
854//
855// Actually creates the ActiveX container through the FrameSite
856// and sets up ActiveX events
857//
858// TODO: Document this more
859//---------------------------------------------------------------------------
bf354396
VZ
860void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
861{
862 HRESULT hret;
863 hret = m_ActiveX.QueryInterface(iid, pUnk);
f1430ac7 864 CHECK_HR(hret);
bf354396
VZ
865
866 // FrameSite
9b53796d 867 m_frameSite = new FrameSite(m_realparent, this);
bf354396
VZ
868 // oleClientSite
869 hret = m_clientSite.QueryInterface(
9b53796d 870 IID_IOleClientSite, (IDispatch *) m_frameSite);
f1430ac7 871 CHECK_HR(hret);
bf354396 872 // adviseSink
9b53796d 873 wxAutoIAdviseSink adviseSink(IID_IAdviseSink, (IDispatch *) m_frameSite);
bf354396
VZ
874 wxASSERT(adviseSink.Ok());
875
876 // Get Dispatch interface
877 hret = m_Dispatch.QueryInterface(IID_IDispatch, m_ActiveX);
f1430ac7 878 CHECK_HR(hret);
bf354396 879
557002cf
VZ
880 //
881 // SETUP TYPEINFO AND ACTIVEX EVENTS
882 //
883
884 // get type info via class info
885 wxAutoIProvideClassInfo classInfo(IID_IProvideClassInfo, m_ActiveX);
886 wxASSERT(classInfo.Ok());
887
888 // type info
889 wxAutoITypeInfo typeInfo;
890 hret = classInfo->GetClassInfo(typeInfo.GetRef());
f1430ac7 891 CHECK_HR(hret);
557002cf
VZ
892 wxASSERT(typeInfo.Ok());
893
894 // TYPEATTR
895 TYPEATTR *ta = NULL;
896 hret = typeInfo->GetTypeAttr(&ta);
f1430ac7 897 CHECK_HR(hret);
557002cf
VZ
898
899 // this should be a TKIND_COCLASS
900 wxASSERT(ta->typekind == TKIND_COCLASS);
901
902 // iterate contained interfaces
903 for (int i = 0; i < ta->cImplTypes; i++)
904 {
905 HREFTYPE rt = 0;
906
907 // get dispatch type info handle
908 hret = typeInfo->GetRefTypeOfImplType(i, &rt);
909 if (! SUCCEEDED(hret))
910 continue;
911
912 // get dispatch type info interface
913 wxAutoITypeInfo ti;
914 hret = typeInfo->GetRefTypeInfo(rt, ti.GetRef());
915 if (! ti.Ok())
916 continue;
917
f1430ac7
VZ
918 CHECK_HR(hret);
919
557002cf 920 // check if default event sink
557002cf
VZ
921 bool defEventSink = false;
922 int impTypeFlags = 0;
923 typeInfo->GetImplTypeFlags(i, &impTypeFlags);
924
925 if (impTypeFlags & IMPLTYPEFLAG_FDEFAULT)
926 {
927 if (impTypeFlags & IMPLTYPEFLAG_FSOURCE)
928 {
929 // WXOLE_TRACEOUT("Default Event Sink");
930 defEventSink = true;
931 if (impTypeFlags & IMPLTYPEFLAG_FDEFAULTVTABLE)
932 {
933 // WXOLE_TRACEOUT("*ERROR* - Default Event Sink is via vTable");
934 defEventSink = false;
935 wxFAIL_MSG(wxT("Default event sink is in vtable!"));
936 }
937 }
557002cf
VZ
938 }
939
940
941 // wxAutoOleInterface<> assumes a ref has already been added
942 // TYPEATTR
943 TYPEATTR *ta = NULL;
944 hret = ti->GetTypeAttr(&ta);
f1430ac7 945 CHECK_HR(hret);
557002cf
VZ
946
947 if (ta->typekind == TKIND_DISPATCH)
948 {
949 // WXOLE_TRACEOUT("GUID = " << GetIIDName(ta->guid).c_str());
950 if (defEventSink)
951 {
952 wxAutoIConnectionPoint cp;
953 DWORD adviseCookie = 0;
954
955 wxAutoIConnectionPointContainer cpContainer(IID_IConnectionPointContainer, m_ActiveX);
956 wxASSERT( cpContainer.Ok());
957
958 HRESULT hret =
959 cpContainer->FindConnectionPoint(ta->guid, cp.GetRef());
f1430ac7 960 CHECK_HR(hret);
557002cf
VZ
961
962 IDispatch* disp;
9b53796d 963 m_frameSite->QueryInterface(IID_IDispatch, (void**)&disp);
557002cf
VZ
964 hret = cp->Advise(new wxActiveXEvents(this, ta->guid),
965 &adviseCookie);
f1430ac7 966 CHECK_HR(hret);
557002cf
VZ
967 }
968 }
969
970 ti->ReleaseTypeAttr(ta);
971 }
972
973 // free
974 typeInfo->ReleaseTypeAttr(ta);
975
976 //
977 // END
978 //
979
bf354396
VZ
980 // Get IOleObject interface
981 hret = m_oleObject.QueryInterface(IID_IOleObject, m_ActiveX);
f1430ac7 982 CHECK_HR(hret);
bf354396
VZ
983
984 // get IViewObject Interface
985 hret = m_viewObject.QueryInterface(IID_IViewObject, m_ActiveX);
f1430ac7 986 CHECK_HR(hret);
bf354396
VZ
987
988 // document advise
989 m_docAdviseCookie = 0;
990 hret = m_oleObject->Advise(adviseSink, &m_docAdviseCookie);
f1430ac7
VZ
991 CHECK_HR(hret);
992
557002cf
VZ
993 // TODO:Needed?
994// hret = m_viewObject->SetAdvise(DVASPECT_CONTENT, 0, adviseSink);
bf354396
VZ
995 m_oleObject->SetHostNames(L"wxActiveXContainer", NULL);
996 OleSetContainedObject(m_oleObject, TRUE);
997 OleRun(m_oleObject);
998
999
1000 // Get IOleInPlaceObject interface
1001 hret = m_oleInPlaceObject.QueryInterface(
1002 IID_IOleInPlaceObject, m_ActiveX);
f1430ac7 1003 CHECK_HR(hret);
bf354396
VZ
1004
1005 // status
1006 DWORD dwMiscStatus;
1007 m_oleObject->GetMiscStatus(DVASPECT_CONTENT, &dwMiscStatus);
f1430ac7 1008 CHECK_HR(hret);
bf354396
VZ
1009
1010 // set client site first ?
1011 if (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST)
1012 m_oleObject->SetClientSite(m_clientSite);
1013
1014
1015 // stream init
1016 wxAutoIPersistStreamInit
1017 pPersistStreamInit(IID_IPersistStreamInit, m_oleObject);
1018
1019 if (pPersistStreamInit.Ok())
1020 {
1021 hret = pPersistStreamInit->InitNew();
f1430ac7 1022 CHECK_HR(hret);
bf354396
VZ
1023 }
1024
1025 if (! (dwMiscStatus & OLEMISC_SETCLIENTSITEFIRST))
1026 m_oleObject->SetClientSite(m_clientSite);
1027
1028
bf354396
VZ
1029 m_oleObjectHWND = 0;
1030
1031 if (m_oleInPlaceObject.Ok())
1032 {
1033 hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
1034 if (SUCCEEDED(hret))
1035 ::SetActiveWindow(m_oleObjectHWND);
1036 }
1037
1038
1039 if (! (dwMiscStatus & OLEMISC_INVISIBLEATRUNTIME))
1040 {
0641c712
VZ
1041 RECT posRect;
1042 wxCopyRectToRECT(m_realparent->GetClientSize(), posRect);
1043
bf354396
VZ
1044 if (posRect.right > 0 && posRect.bottom > 0 &&
1045 m_oleInPlaceObject.Ok())
0641c712
VZ
1046 {
1047 m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
1048 }
bf354396
VZ
1049
1050 hret = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL,
1051 m_clientSite, 0, (HWND)m_realparent->GetHWND(), &posRect);
f1430ac7
VZ
1052 CHECK_HR(hret);
1053
bf354396
VZ
1054 hret = m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0,
1055 (HWND)m_realparent->GetHWND(), &posRect);
f1430ac7 1056 CHECK_HR(hret);
bf354396
VZ
1057 }
1058
1059 if (! m_oleObjectHWND && m_oleInPlaceObject.Ok())
1060 {
1061 hret = m_oleInPlaceObject->GetWindow(&m_oleObjectHWND);
f1430ac7 1062 CHECK_HR(hret);
bf354396
VZ
1063 }
1064
1065 if (m_oleObjectHWND)
1066 {
1067 ::SetActiveWindow(m_oleObjectHWND);
1068 ::ShowWindow(m_oleObjectHWND, SW_SHOW);
1069
f36b056b 1070 this->AssociateHandle(m_oleObjectHWND);
bf354396
VZ
1071 this->Reparent(m_realparent);
1072
1073 wxWindow* pWnd = m_realparent;
1074 int id = m_realparent->GetId();
1075
1076 pWnd->Connect(id, wxEVT_SIZE,
1077 wxSizeEventHandler(wxActiveXContainer::OnSize), 0, this);
557002cf
VZ
1078// this->Connect(GetId(), wxEVT_PAINT,
1079// wxPaintEventHandler(wxActiveXContainer::OnPaint), 0, this);
bf354396
VZ
1080 pWnd->Connect(id, wxEVT_SET_FOCUS,
1081 wxFocusEventHandler(wxActiveXContainer::OnSetFocus), 0, this);
1082 pWnd->Connect(id, wxEVT_KILL_FOCUS,
1083 wxFocusEventHandler(wxActiveXContainer::OnKillFocus), 0, this);
1084 }
1085}
1086
557002cf
VZ
1087//---------------------------------------------------------------------------
1088// wxActiveXContainer::OnSize
1089//
1090// Called when the parent is resized - we need to do this to actually
1091// move the ActiveX control to where the parent is
1092//---------------------------------------------------------------------------
bf354396
VZ
1093void wxActiveXContainer::OnSize(wxSizeEvent& event)
1094{
1095 int w, h;
1096 GetParent()->GetClientSize(&w, &h);
1097
1098 RECT posRect;
1099 posRect.left = 0;
1100 posRect.top = 0;
1101 posRect.right = w;
1102 posRect.bottom = h;
1103
1104 if (w <= 0 && h <= 0)
1105 return;
1106
1107 // extents are in HIMETRIC units
1108 if (m_oleObject.Ok())
1109 {
557002cf
VZ
1110 m_oleObject->DoVerb(OLEIVERB_HIDE, 0, m_clientSite, 0,
1111 (HWND)m_realparent->GetHWND(), &posRect);
1112
bf354396
VZ
1113 SIZEL sz = {w, h};
1114 PixelsToHimetric(sz);
1115
1116 SIZEL sz2;
1117
1118 m_oleObject->GetExtent(DVASPECT_CONTENT, &sz2);
1119 if (sz2.cx != sz.cx || sz.cy != sz2.cy)
1120 m_oleObject->SetExtent(DVASPECT_CONTENT, &sz);
557002cf
VZ
1121
1122 m_oleObject->DoVerb(OLEIVERB_SHOW, 0, m_clientSite, 0,
1123 (HWND)m_realparent->GetHWND(), &posRect);
1124 }
bf354396
VZ
1125
1126 if (m_oleInPlaceObject.Ok())
1127 m_oleInPlaceObject->SetObjectRects(&posRect, &posRect);
1128
1129 event.Skip();
1130}
1131
557002cf
VZ
1132//---------------------------------------------------------------------------
1133// wxActiveXContainer::OnPaint
1134//
1135// Called when the parent is resized - repaints the ActiveX control
1136//---------------------------------------------------------------------------
bf354396
VZ
1137void wxActiveXContainer::OnPaint(wxPaintEvent& WXUNUSED(event))
1138{
1139 wxPaintDC dc(this);
1140 // Draw only when control is windowless or deactivated
1141 if (m_viewObject)
1142 {
bf354396
VZ
1143 int w, h;
1144 GetParent()->GetSize(&w, &h);
1145 RECT posRect;
1146 posRect.left = 0;
1147 posRect.top = 0;
1148 posRect.right = w;
1149 posRect.bottom = h;
1150
5d484919 1151#if !(defined(_WIN32_WCE) && _WIN32_WCE < 400)
bf354396 1152 ::RedrawWindow(m_oleObjectHWND, NULL, NULL, RDW_INTERNALPAINT);
5d484919
WS
1153#else
1154 ::InvalidateRect(m_oleObjectHWND, NULL, false);
1155#endif
bf354396 1156 RECTL *prcBounds = (RECTL *) &posRect;
0290aeac 1157 wxMSWDCImpl *msw = wxDynamicCast( dc.GetImpl() , wxMSWDCImpl );
bf354396 1158 m_viewObject->Draw(DVASPECT_CONTENT, -1, NULL, NULL, NULL,
0290aeac 1159 (HDC)msw->GetHDC(), prcBounds, NULL, NULL, 0);
557002cf 1160 }
bf354396
VZ
1161}
1162
557002cf
VZ
1163//---------------------------------------------------------------------------
1164// wxActiveXContainer::OnSetFocus
1165//
1166// Called when the focus is set on the parent - activates the activex control
1167//---------------------------------------------------------------------------
bf354396
VZ
1168void wxActiveXContainer::OnSetFocus(wxFocusEvent& event)
1169{
1170 if (m_oleInPlaceActiveObject.Ok())
1171 m_oleInPlaceActiveObject->OnFrameWindowActivate(TRUE);
1172
1173 event.Skip();
1174}
1175
557002cf
VZ
1176//---------------------------------------------------------------------------
1177// wxActiveXContainer::OnKillFocus
1178//
1179// Called when the focus is killed on the parent -
1180// deactivates the activex control
1181//---------------------------------------------------------------------------
bf354396
VZ
1182void wxActiveXContainer::OnKillFocus(wxFocusEvent& event)
1183{
1184 if (m_oleInPlaceActiveObject.Ok())
1185 m_oleInPlaceActiveObject->OnFrameWindowActivate(FALSE);
1186
1187 event.Skip();
1188}
557002cf 1189
a1f48575 1190#endif // wxUSE_ACTIVEX