1 /************************************************************************* 2 * 3 * The Contents of this file are made available subject to the terms of 4 * the BSD license. 5 * 6 * Copyright 2000, 2010 Oracle and/or its affiliates. 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 30 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 31 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 *************************************************************************/ 34 35 // SOComWindowPeer.h: Definition of the SOComWindowPeer class 36 // 37 ////////////////////////////////////////////////////////////////////// 38 39 #if !defined __SOCOMWINDOWPEER_H_ 40 #define __SOCOMWINDOWPEER_H_ 41 42 #if _MSC_VER > 1000 43 #pragma once 44 #endif // _MSC_VER > 1000 45 46 #include "resource.h" // main symbols 47 #include <ExDispID.h> 48 #include <ExDisp.h> 49 #include <shlguid.h> 50 #include <atlctl.h> 51 52 #include "so_activex.h" 53 54 ///////////////////////////////////////////////////////////////////////////// 55 // SOComWindowPeer 56 57 class SOComWindowPeer : 58 public IDispatchImpl<ISOComWindowPeer, &IID_ISOComWindowPeer, &LIBID_SO_ACTIVEXLib>, 59 public ISupportErrorInfo, 60 public CComObjectRoot, 61 public CComCoClass<SOComWindowPeer,&CLSID_SOComWindowPeer> 62 { 63 HWND m_hwnd; 64 public: 65 SOComWindowPeer() : m_hwnd( NULL ) {} 66 67 BEGIN_COM_MAP(SOComWindowPeer) 68 COM_INTERFACE_ENTRY(IDispatch) 69 COM_INTERFACE_ENTRY(ISOComWindowPeer) 70 COM_INTERFACE_ENTRY(ISupportErrorInfo) 71 END_COM_MAP() 72 DECLARE_NOT_AGGREGATABLE(SOComWindowPeer) 73 // Remove the comment from the line above if you don't want your object to 74 // support aggregation. 75 76 DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER) 77 78 // ISupportsErrorInfo 79 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); 80 81 // ISOComWindowPeer 82 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getWindowHandle( 83 /* [in] */ SAFEARRAY __RPC_FAR * procId, 84 /* [in] */ short s, 85 /* [retval][out] */ long __RPC_FAR *ret) 86 { 87 *ret = (long) m_hwnd; 88 return S_OK; 89 } 90 91 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getToolkit( 92 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) 93 { 94 *retVal = NULL; 95 return S_OK; 96 } 97 98 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setPointer( 99 /* [in] */ IDispatch __RPC_FAR *xPointer) 100 { 101 return S_OK; 102 } 103 104 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setBackground( 105 /* [in] */ int nColor) 106 { 107 return S_OK; 108 } 109 110 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidate( 111 /* [in] */ short __MIDL_0015) 112 { 113 return S_OK; 114 } 115 116 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidateRect( 117 /* [in] */ IDispatch __RPC_FAR *aRect, 118 /* [in] */ short nFlags) 119 { 120 return S_OK; 121 } 122 123 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispose( void) 124 { 125 return S_OK; 126 } 127 128 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addEventListener( 129 /* [in] */ IDispatch __RPC_FAR *xListener) 130 { 131 return S_OK; 132 } 133 134 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeEventListener( 135 /* [in] */ IDispatch __RPC_FAR *xListener) 136 { 137 return S_OK; 138 } 139 140 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces( 141 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) 142 { 143 *pVal = SafeArrayCreateVector( VT_BSTR, 0, 2 ); 144 145 if( !*pVal ) 146 return E_FAIL; 147 148 long ix = 0; 149 CComBSTR aInterface( OLESTR( "com.sun.star.awt.XSystemDependentWindowPeer" ) ); 150 SafeArrayPutElement( *pVal, &ix, aInterface ); 151 152 ix = 1; 153 aInterface = CComBSTR( OLESTR( "com.sun.star.awt.XWindowPeer" ) ); 154 SafeArrayPutElement( *pVal, &ix, aInterface ); 155 156 return S_OK; 157 } 158 159 void SetHWNDInternally( HWND hwnd ) { m_hwnd = hwnd; } 160 }; 161 162 #endif // __SOCOMWINDOWPEER_H_ 163