Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
7.0 KiB

  1. // PrevCtrl.h : Declaration of the CPreview
  2. #ifndef __PREVCTRL_H_
  3. #define __PREVCTRL_H_
  4. #include "resource.h" // main symbols
  5. #include "PrevWnd.h"
  6. #include "Events.h"
  7. int IsVK_TABCycler(MSG *pMsg);
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CPreview
  10. class ATL_NO_VTABLE CPreview :
  11. public CComObjectRootEx<CComSingleThreadModel>,
  12. public CComCoClass<CPreview, &CLSID_Preview>,
  13. public CComControl<CPreview>,
  14. public CStockPropImpl<CPreview, IPreview2, &IID_IPreview2, &LIBID_PREVIEWLib>,
  15. public CStockPropImpl<CPreview, IPreview3, &IID_IPreview3, &LIBID_PREVIEWLib>,
  16. public IProvideClassInfo2Impl<&CLSID_Preview, NULL, &LIBID_PREVIEWLib>,
  17. public IPersistPropertyBagImpl<CPreview>, // So we can read <PARAM>'s from our object tag
  18. public IPersistStorageImpl<CPreview>, // required for Embeddable objects
  19. public IOleObjectImpl<CPreview>, // required for Embeddable objects
  20. public IDataObjectImpl<CPreview>, // required for Embeddable objects
  21. public IQuickActivateImpl<CPreview>,
  22. public IOleControlImpl<CPreview>, // REVIEW: will IOleControl::GetControlInfo help with my keyboard problems?
  23. public IOleInPlaceActiveObjectImpl<CPreview>, // handles resizing, active state, TranslateAccelerator
  24. public IViewObjectExImpl<CPreview>, // for flicker-free drawing support
  25. public IOleInPlaceObjectWindowlessImpl<CPreview>, // allow for windowless operation (we don't use windowless, should we be using this interface?)
  26. public CPreviewEvents<CPreview>, // our event code for sending events to our container
  27. public IConnectionPointContainerImpl<CPreview>, // Connection Point Container for our outgoing event hooks.
  28. public IObjectSafetyImpl<CPreview, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>,// allows this control to be scripted
  29. public IPersistStreamInitImpl<CPreview>,
  30. public IObjectWithSiteImpl<CPreview>
  31. {
  32. private:
  33. DWORD _dwConnectionCookie;
  34. IFolderView *_pfv;
  35. public:
  36. CPreviewWnd m_cwndPreview;
  37. CPreview()
  38. {
  39. // we want to be run in a window and never windowless
  40. m_bWindowOnly = TRUE;
  41. m_cwndPreview.Initialize(NULL, CONTROL_MODE, FALSE); // ISSUE: we don't handle failure of initialization in low-memory case
  42. }
  43. ~CPreview()
  44. {
  45. ATOMICRELEASE(_pfv);
  46. }
  47. DECLARE_REGISTRY_RESOURCEID(IDR_PREVIEW)
  48. DECLARE_WND_CLASS( TEXT("ShImgVw:CPreview") );
  49. BEGIN_COM_MAP(CPreview)
  50. COM_INTERFACE_ENTRY(IPreview2)
  51. COM_INTERFACE_ENTRY(IPreview3)
  52. COM_INTERFACE_ENTRY_IID(IID_IDispatch, IPreview2)
  53. COM_INTERFACE_ENTRY_IID(IID_IPreview, IPreview2)
  54. COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
  55. COM_INTERFACE_ENTRY(IObjectSafety)
  56. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
  57. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
  58. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
  59. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  60. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  61. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
  62. COM_INTERFACE_ENTRY_IMPL(IOleControl)
  63. COM_INTERFACE_ENTRY_IMPL(IOleObject)
  64. COM_INTERFACE_ENTRY_IMPL(IObjectWithSite)
  65. COM_INTERFACE_ENTRY_IMPL(IQuickActivate)
  66. COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag)
  67. COM_INTERFACE_ENTRY_IMPL(IPersistStorage)
  68. COM_INTERFACE_ENTRY(IPersistStreamInit)
  69. COM_INTERFACE_ENTRY_IMPL(IDataObject)
  70. COM_INTERFACE_ENTRY(IProvideClassInfo)
  71. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  72. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  73. END_COM_MAP()
  74. BEGIN_CONNECTION_POINT_MAP(CPreview)
  75. CONNECTION_POINT_ENTRY(DIID_DPreviewEvents)
  76. END_CONNECTION_POINT_MAP()
  77. BEGIN_PROPERTY_MAP(CPreview)
  78. PROP_PAGE(CLSID_StockColorPage)
  79. END_PROPERTY_MAP()
  80. BEGIN_MSG_MAP(CPreview)
  81. MESSAGE_HANDLER(WM_CREATE, OnCreate)
  82. MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd)
  83. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  84. MESSAGE_HANDLER(WM_PAINT, OnPaint)
  85. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  86. MESSAGE_HANDLER(WM_SIZE, OnSize)
  87. MESSAGE_HANDLER(WM_ACTIVATE, OnActivate)
  88. END_MSG_MAP()
  89. // IViewObjectEx
  90. STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
  91. {
  92. ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
  93. *pdwStatus = VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE;
  94. return S_OK;
  95. }
  96. // IOleInPlaceActiveObjectImpl
  97. STDMETHOD(TranslateAccelerator)( LPMSG lpmsg );
  98. STDMETHOD(OnFrameWindowActivate)( BOOL fActive );
  99. // IPersistPropertyBag
  100. STDMETHOD(Load)(IPropertyBag * pPropBag, IErrorLog * pErrorLog);
  101. STDMETHOD(Save)(IPropertyBag * pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) {return S_OK;}
  102. // IObjectSafety
  103. STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions);
  104. STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid, DWORD dwSupportedOptions, DWORD dwEnabledOptions);
  105. // IPersistStreamInit
  106. STDMETHOD(Load)(IStream * pStm);
  107. STDMETHOD(Save)(IStream * pStm, BOOL fClearDirty) {return S_OK;}
  108. // IOleObject
  109. STDMETHODIMP SetClientSite(IOleClientSite *pClientSite);
  110. // IObjectWithSite
  111. STDMETHODIMP SetSite(IUnknown* punkSite);
  112. // IDispatch
  113. STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams,
  114. VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
  115. public:
  116. // Control message handlers
  117. LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  118. LRESULT OnActivate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  119. LRESULT OnSetFocus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  120. HRESULT OnDrawAdvanced(ATL_DRAWINFO& di);
  121. LRESULT OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  122. LRESULT OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  123. public:
  124. // IPreview, IPreview3
  125. STDMETHOD(get_printable)(/*[out, retval]*/ BOOL *pVal);
  126. STDMETHOD(put_printable)(/*[in]*/ BOOL newVal);
  127. STDMETHOD(get_cxImage)(/*[out, retval]*/ long *pVal);
  128. STDMETHOD(get_cyImage)(/*[out, retval]*/ long *pVal);
  129. STDMETHOD(ShowFile)(BSTR bstrFileName, int iSelectCount);
  130. STDMETHOD(Show)(VARIANT var);
  131. // IPreview2, IPreview3
  132. STDMETHOD(Zoom)(/*[in]*/ int iSelectCount);
  133. STDMETHOD(BestFit)();
  134. STDMETHOD(ActualSize)();
  135. STDMETHOD(SlideShow)();
  136. // IPreview3
  137. STDMETHOD(Rotate)(/*[in]*/ DWORD dwAngle);
  138. STDMETHOD(SaveAs)(/*[in]*/BSTR bstrPath);
  139. STDMETHOD(SetWallpaper)(/*[in]*/BSTR bstrWallpaper);
  140. STDMETHOD(ShowFile)(BSTR bstrFileName);
  141. private:
  142. BOOL IsHostLocalZone(DWORD dwFlags, HRESULT *phr);
  143. STDMETHOD(_ProcessSelection) (void);
  144. };
  145. #endif //__PREVCTRL_H_