xref: /aoo42x/main/odk/examples/OLE/activex/SOActiveX.h (revision 34dd1e25)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // SOActiveX.h : Declaration of the CSOActiveX
25 
26 #ifndef __SOACTIVEX_H_
27 #define __SOACTIVEX_H_
28 
29 #include "resource.h"       // main symbols
30 #include <ExDispID.h>
31 #include <ExDisp.h>
32 #include <shlguid.h>
33 #include <atlctl.h>
34 
35 #include "so_activex.h"
36 
37 /////////////////////////////////////////////////////////////////////////////
38 // CSOActiveX
39 class ATL_NO_VTABLE CSOActiveX :
40 	public CComObjectRootEx<CComSingleThreadModel>,
41 	public IDispatchImpl<ISOActiveX, &IID_ISOActiveX, &LIBID_SO_ACTIVEXLib>,
42 	public CComControl<CSOActiveX>,
43 	public IPersistStreamInitImpl<CSOActiveX>,
44 	public IOleControlImpl<CSOActiveX>,
45 	public IOleObjectImpl<CSOActiveX>,
46 	public IOleInPlaceActiveObjectImpl<CSOActiveX>,
47 	public IViewObjectExImpl<CSOActiveX>,
48 	public IOleInPlaceObjectWindowlessImpl<CSOActiveX>,
49 //	public IConnectionPointContainerImpl<CSOActiveX>,
50 	public CComCoClass<CSOActiveX, &CLSID_SOActiveX>,
51 //	public CProxy_ItryPluginEvents< CSOActiveX >,
52 	public IPersistPropertyBagImpl< CSOActiveX >,
53 	public IProvideClassInfo2Impl<	&CLSID_SOActiveX,
54 									&DIID__ISOActiveXEvents,
55 									&LIBID_SO_ACTIVEXLib >,
56     public IObjectSafetyImpl< CSOActiveX,
57                               INTERFACESAFE_FOR_UNTRUSTED_DATA >
58 {
59 protected:
60 	CComPtr<IWebBrowser2>	mWebBrowser2;
61 	DWORD					mCookie;
62 
63 	CComPtr<IDispatch> 		mpDispFactory;
64 	CComPtr<IDispatch> 		mpDispFrame;
65 	CComPtr<IDispatch> 		mpDispWin;
66     OLECHAR*          		mCurFileUrl;
67 	BOOL					mbLoad;
68 	BOOL					mbViewOnly;
69     WNDCLASS                mPWinClass;
70 	HWND					mParentWin;
71 	HWND					mOffWin;
72 public:
73 	CSOActiveX();
74 	~CSOActiveX();
75 
76 DECLARE_REGISTRY_RESOURCEID(IDR_SOACTIVEX)
77 
78 DECLARE_PROTECT_FINAL_CONSTRUCT()
79 
80 BEGIN_COM_MAP(CSOActiveX)
81 	COM_INTERFACE_ENTRY(ISOActiveX)
82 	COM_INTERFACE_ENTRY(IDispatch)
83 	COM_INTERFACE_ENTRY(IViewObjectEx)
84 	COM_INTERFACE_ENTRY(IViewObject2)
85 	COM_INTERFACE_ENTRY(IViewObject)
86 	COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
87 	COM_INTERFACE_ENTRY(IOleInPlaceObject)
88 	COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
89 	COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
90 	COM_INTERFACE_ENTRY(IOleControl)
91 	COM_INTERFACE_ENTRY(IOleObject)
92 	COM_INTERFACE_ENTRY(IPersistStreamInit)
93 	COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
94 //	COM_INTERFACE_ENTRY(IConnectionPointContainer)
95 	COM_INTERFACE_ENTRY(IProvideClassInfo)
96 	COM_INTERFACE_ENTRY(IProvideClassInfo2)
97 	COM_INTERFACE_ENTRY(IPersistPropertyBag)
98 	COM_INTERFACE_ENTRY(IObjectSafety)
99 END_COM_MAP()
100 
101 BEGIN_PROP_MAP(CSOActiveX)
102 	PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
103 	PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
104 	// Example entries
105 	// PROP_ENTRY("Property Description", dispid, clsid)
106 	// PROP_PAGE(CLSID_StockColorPage)
107 END_PROP_MAP()
108 
109 BEGIN_CONNECTION_POINT_MAP(CSOActiveX)
110 END_CONNECTION_POINT_MAP()
111 
112 BEGIN_MSG_MAP(CSOActiveX)
113 	CHAIN_MSG_MAP(CComControl<CSOActiveX>)
114 	DEFAULT_REFLECTION_HANDLER()
115 END_MSG_MAP()
116 // Handler prototypes:
117 //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
118 //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
119 //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
120 
121 
122 
123 // IViewObjectEx
124 	DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
125 
126 // ISOActiveX
127 public:
128 
129 	STDMETHOD(SetClientSite)( IOleClientSite* aClientSite );
130 	STDMETHOD(Invoke)(  DISPID dispidMember,
131 						REFIID riid,
132 						LCID lcid,
133                         WORD wFlags,
134 						DISPPARAMS* pDispParams,
135                         VARIANT* pvarResult,
136 						EXCEPINFO* pExcepInfo,
137                         UINT* puArgErr);
138 	STDMETHOD(Load) ( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog );
139 	STDMETHOD(Load) ( LPSTREAM pStm );
140     STDMETHOD(InitNew) ();
141 	HRESULT OnDrawAdvanced(ATL_DRAWINFO& di);
OnDraw(ATL_DRAWINFO & di)142 	HRESULT OnDraw(ATL_DRAWINFO& di) { return S_OK; }
143 
144 	HRESULT CreateFrameOldWay( HWND hwnd, int width, int height );
145 	HRESULT GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult );
146 	HRESULT LoadURLToFrame();
147 	HRESULT ShowSomeBars();
148 	HRESULT HideAllBars();
149 	HRESULT CallDispatch1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal );
150 	HRESULT GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl );
151 	HRESULT	Cleanup();
152 };
153 
154 #endif //__SOACTIVEX_H_
155 
156