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