// PrevCtrl.h : Declaration of the CPreview #ifndef __PREVCTRL_H_ #define __PREVCTRL_H_ #include "resource.h" // main symbols #include "PrevWnd.h" #include "Events.h" int IsVK_TABCycler(MSG *pMsg); ///////////////////////////////////////////////////////////////////////////// // CPreview class ATL_NO_VTABLE CPreview : public CComObjectRootEx, public CComCoClass, public CComControl, public CStockPropImpl, public CStockPropImpl, public IProvideClassInfo2Impl<&CLSID_Preview, NULL, &LIBID_PREVIEWLib>, public IPersistPropertyBagImpl, // So we can read 's from our object tag public IPersistStorageImpl, // required for Embeddable objects public IOleObjectImpl, // required for Embeddable objects public IDataObjectImpl, // required for Embeddable objects public IQuickActivateImpl, public IOleControlImpl, // REVIEW: will IOleControl::GetControlInfo help with my keyboard problems? public IOleInPlaceActiveObjectImpl, // handles resizing, active state, TranslateAccelerator public IViewObjectExImpl, // for flicker-free drawing support public IOleInPlaceObjectWindowlessImpl, // allow for windowless operation (we don't use windowless, should we be using this interface?) public CPreviewEvents, // our event code for sending events to our container public IConnectionPointContainerImpl, // Connection Point Container for our outgoing event hooks. public IObjectSafetyImpl,// allows this control to be scripted public IPersistStreamInitImpl, public IObjectWithSiteImpl { private: DWORD _dwConnectionCookie; IFolderView *_pfv; public: CPreviewWnd m_cwndPreview; CPreview() { // we want to be run in a window and never windowless m_bWindowOnly = TRUE; m_cwndPreview.Initialize(NULL, CONTROL_MODE, FALSE); // ISSUE: we don't handle failure of initialization in low-memory case } ~CPreview() { ATOMICRELEASE(_pfv); } DECLARE_REGISTRY_RESOURCEID(IDR_PREVIEW) DECLARE_WND_CLASS( TEXT("ShImgVw:CPreview") ); BEGIN_COM_MAP(CPreview) COM_INTERFACE_ENTRY(IPreview2) COM_INTERFACE_ENTRY(IPreview3) COM_INTERFACE_ENTRY_IID(IID_IDispatch, IPreview2) COM_INTERFACE_ENTRY_IID(IID_IPreview, IPreview2) COM_INTERFACE_ENTRY_IMPL(IViewObjectEx) COM_INTERFACE_ENTRY(IObjectSafety) COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx) COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx) COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless) COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject) COM_INTERFACE_ENTRY_IMPL(IOleControl) COM_INTERFACE_ENTRY_IMPL(IOleObject) COM_INTERFACE_ENTRY_IMPL(IObjectWithSite) COM_INTERFACE_ENTRY_IMPL(IQuickActivate) COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag) COM_INTERFACE_ENTRY_IMPL(IPersistStorage) COM_INTERFACE_ENTRY(IPersistStreamInit) COM_INTERFACE_ENTRY_IMPL(IDataObject) COM_INTERFACE_ENTRY(IProvideClassInfo) COM_INTERFACE_ENTRY(IProvideClassInfo2) COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer) END_COM_MAP() BEGIN_CONNECTION_POINT_MAP(CPreview) CONNECTION_POINT_ENTRY(DIID_DPreviewEvents) END_CONNECTION_POINT_MAP() BEGIN_PROPERTY_MAP(CPreview) PROP_PAGE(CLSID_StockColorPage) END_PROPERTY_MAP() BEGIN_MSG_MAP(CPreview) MESSAGE_HANDLER(WM_CREATE, OnCreate) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus) MESSAGE_HANDLER(WM_PAINT, OnPaint) MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) MESSAGE_HANDLER(WM_SIZE, OnSize) MESSAGE_HANDLER(WM_ACTIVATE, OnActivate) END_MSG_MAP() // IViewObjectEx STDMETHOD(GetViewStatus)(DWORD* pdwStatus) { ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n")); *pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE; return S_OK; } // IOleInPlaceActiveObjectImpl STDMETHOD(TranslateAccelerator)( LPMSG lpmsg ); STDMETHOD(OnFrameWindowActivate)( BOOL fActive ); // IPersistPropertyBag STDMETHOD(Load)(IPropertyBag * pPropBag, IErrorLog * pErrorLog); STDMETHOD(Save)(IPropertyBag * pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) {return S_OK;} // IObjectSafety STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions); STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid, DWORD dwSupportedOptions, DWORD dwEnabledOptions); // IPersistStreamInit STDMETHOD(Load)(IStream * pStm); STDMETHOD(Save)(IStream * pStm, BOOL fClearDirty) {return S_OK;} // IOleObject STDMETHODIMP SetClientSite(IOleClientSite *pClientSite); // IObjectWithSite STDMETHODIMP SetSite(IUnknown* punkSite); // IDispatch STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr); public: // Control message handlers LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); HRESULT OnDrawAdvanced(ATL_DRAWINFO& di); LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled); public: // IPreview, IPreview3 STDMETHOD(get_printable)(/*[out, retval]*/ BOOL *pVal); STDMETHOD(put_printable)(/*[in]*/ BOOL newVal); STDMETHOD(get_cxImage)(/*[out, retval]*/ long *pVal); STDMETHOD(get_cyImage)(/*[out, retval]*/ long *pVal); STDMETHOD(ShowFile)(BSTR bstrFileName, int iSelectCount); STDMETHOD(Show)(VARIANT var); // IPreview2, IPreview3 STDMETHOD(Zoom)(/*[in]*/ int iSelectCount); STDMETHOD(BestFit)(); STDMETHOD(ActualSize)(); STDMETHOD(SlideShow)(); // IPreview3 STDMETHOD(Rotate)(/*[in]*/ DWORD dwAngle); STDMETHOD(SaveAs)(/*[in]*/BSTR bstrPath); STDMETHOD(SetWallpaper)(/*[in]*/BSTR bstrWallpaper); STDMETHOD(ShowFile)(BSTR bstrFileName); private: BOOL IsHostLocalZone(DWORD dwFlags, HRESULT *phr); STDMETHOD(_ProcessSelection) (void); }; #endif //__PREVCTRL_H_