1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /************************************************************************* 3 * 4 * The Contents of this file are made available subject to the terms of 5 * the BSD license. 6 * 7 * Copyright 2000, 2010 Oracle and/or its affiliates. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 31 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 32 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * 34 *************************************************************************/ 35 36 // SOActiveX.h : Declaration of the CSOActiveX 37 38 #ifndef INCLUDED_EXAMPLES_ACTIVEX_SOACTIVEX_H 39 #define INCLUDED_EXAMPLES_ACTIVEX_SOACTIVEX_H 40 41 #include "resource.h" 42 #include <ExDispID.h> 43 #include <ExDisp.h> 44 #include <shlguid.h> 45 #include <atlctl.h> 46 47 #include "so_activex.h" 48 49 50 // CSOActiveX 51 class ATL_NO_VTABLE CSOActiveX : 52 public CComObjectRootEx<CComSingleThreadModel>, 53 public IDispatchImpl<ISOActiveX, &IID_ISOActiveX, &LIBID_SO_ACTIVEXLib>, 54 public CComControl<CSOActiveX>, 55 public IPersistStreamInitImpl<CSOActiveX>, 56 public IOleControlImpl<CSOActiveX>, 57 public IOleObjectImpl<CSOActiveX>, 58 public IOleInPlaceActiveObjectImpl<CSOActiveX>, 59 public IViewObjectExImpl<CSOActiveX>, 60 public IOleInPlaceObjectWindowlessImpl<CSOActiveX>, 61 // public IConnectionPointContainerImpl<CSOActiveX>, 62 public CComCoClass<CSOActiveX, &CLSID_SOActiveX>, 63 // public CProxy_ItryPluginEvents< CSOActiveX >, 64 public IPersistPropertyBagImpl< CSOActiveX >, 65 public IProvideClassInfo2Impl< &CLSID_SOActiveX, 66 &DIID__ISOActiveXEvents, 67 &LIBID_SO_ACTIVEXLib >, 68 public IObjectSafetyImpl< CSOActiveX, 69 INTERFACESAFE_FOR_UNTRUSTED_DATA > 70 { 71 protected: 72 CComPtr<IWebBrowser2> mWebBrowser2; 73 DWORD mCookie; 74 75 CComPtr<IDispatch> mpDispFactory; 76 CComPtr<IDispatch> mpDispFrame; 77 CComPtr<IDispatch> mpDispWin; 78 OLECHAR* mCurFileUrl; 79 BOOL mbLoad; 80 BOOL mbViewOnly; 81 WNDCLASS mPWinClass; 82 HWND mParentWin; 83 HWND mOffWin; 84 public: 85 CSOActiveX(); 86 ~CSOActiveX(); 87 88 DECLARE_REGISTRY_RESOURCEID(IDR_SOACTIVEX) 89 90 DECLARE_PROTECT_FINAL_CONSTRUCT() 91 92 BEGIN_COM_MAP(CSOActiveX) 93 COM_INTERFACE_ENTRY(ISOActiveX) 94 COM_INTERFACE_ENTRY(IDispatch) 95 COM_INTERFACE_ENTRY(IViewObjectEx) 96 COM_INTERFACE_ENTRY(IViewObject2) 97 COM_INTERFACE_ENTRY(IViewObject) 98 COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless) 99 COM_INTERFACE_ENTRY(IOleInPlaceObject) 100 COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless) 101 COM_INTERFACE_ENTRY(IOleInPlaceActiveObject) 102 COM_INTERFACE_ENTRY(IOleControl) 103 COM_INTERFACE_ENTRY(IOleObject) 104 COM_INTERFACE_ENTRY(IPersistStreamInit) 105 COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit) 106 // COM_INTERFACE_ENTRY(IConnectionPointContainer) 107 COM_INTERFACE_ENTRY(IProvideClassInfo) 108 COM_INTERFACE_ENTRY(IProvideClassInfo2) 109 COM_INTERFACE_ENTRY(IPersistPropertyBag) 110 COM_INTERFACE_ENTRY(IObjectSafety) 111 END_COM_MAP() 112 113 BEGIN_PROP_MAP(CSOActiveX) 114 PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4) 115 PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4) 116 // Example entries 117 // PROP_ENTRY("Property Description", dispid, clsid) 118 // PROP_PAGE(CLSID_StockColorPage) 119 END_PROP_MAP() 120 121 BEGIN_CONNECTION_POINT_MAP(CSOActiveX) 122 END_CONNECTION_POINT_MAP() 123 124 BEGIN_MSG_MAP(CSOActiveX) 125 CHAIN_MSG_MAP(CComControl<CSOActiveX>) 126 DEFAULT_REFLECTION_HANDLER() 127 END_MSG_MAP() 128 // Handler prototypes: 129 // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); 130 // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); 131 // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); 132 133 134 135 // IViewObjectEx 136 DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE) 137 138 // ISOActiveX 139 public: 140 141 STDMETHOD(SetClientSite)( IOleClientSite* aClientSite ); 142 STDMETHOD(Invoke)( DISPID dispidMember, 143 REFIID riid, 144 LCID lcid, 145 WORD wFlags, 146 DISPPARAMS* pDispParams, 147 VARIANT* pvarResult, 148 EXCEPINFO* pExcepInfo, 149 UINT* puArgErr); 150 STDMETHOD(Load) ( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog ); 151 STDMETHOD(Load) ( LPSTREAM pStm ); 152 STDMETHOD(InitNew) (); 153 HRESULT OnDrawAdvanced(ATL_DRAWINFO& di); OnDraw(ATL_DRAWINFO & di)154 HRESULT OnDraw(ATL_DRAWINFO& di) { return S_OK; } 155 156 HRESULT CreateFrameOldWay( HWND hwnd, int width, int height ); 157 HRESULT GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult ); 158 HRESULT LoadURLToFrame(); 159 HRESULT ShowSomeBars(); 160 HRESULT HideAllBars(); 161 HRESULT CallDispatch1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal ); 162 HRESULT GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl ); 163 HRESULT Cleanup(); 164 }; 165 166 #endif // INCLUDED_EXAMPLES_ACTIVEX_SOACTIVEX_H 167 168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 169