home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / atl / atlmovie / moviectl.h < prev    next >
C/C++ Source or Header  |  1998-03-26  |  4KB  |  119 lines

  1. // MovieCtl.h : Declaration of the CMovieCtl
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12.  
  13. #ifndef __MOVIECTL_H_
  14. #define __MOVIECTL_H_
  15.  
  16. #include "resource.h"       // main symbols
  17.  
  18. // This is the ActiveMovie DLL. You might need to specify an explicit path
  19. // here if the DLL isn't intalled along the PATH or INCLUDE directories on
  20. // your machine.
  21. #import <quartz.dll> no_namespace rename("GUID","_GUID")
  22.  
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMovieCtl
  25. class ATL_NO_VTABLE CMovieCtl :
  26.     public CComObjectRootEx<CComSingleThreadModel>,
  27.     public CComCoClass<CMovieCtl, &CLSID_MovieCtl>,
  28.     public IDispatchImpl<IMovieCtl, &IID_IMovieCtl, &LIBID_ATLMOVIELib>,
  29.     public CComControl<CMovieCtl>,
  30.     public IPersistStreamInitImpl<CMovieCtl>,
  31.     public IPersistStorageImpl<CMovieCtl>,
  32.     public IOleControlImpl<CMovieCtl>,
  33.     public IOleObjectImpl<CMovieCtl>,
  34.     public IOleInPlaceActiveObjectImpl<CMovieCtl>,
  35.     public IViewObjectExImpl<CMovieCtl>,
  36.     public IOleInPlaceObjectWindowlessImpl<CMovieCtl>,
  37.     public IProvideClassInfo2Impl<&CLSID_MovieCtl, NULL, &LIBID_ATLMOVIELib>,
  38.     public IObjectSafetyImpl<CMovieCtl, INTERFACESAFE_FOR_UNTRUSTED_CALLER | INTERFACESAFE_FOR_UNTRUSTED_DATA>
  39. {
  40. public:
  41.     CMovieCtl()
  42.     {
  43.  
  44.     }
  45.  
  46. DECLARE_REGISTRY_RESOURCEID(IDR_MOVIECTL)
  47.  
  48. BEGIN_COM_MAP(CMovieCtl)
  49.     COM_INTERFACE_ENTRY(IMovieCtl)
  50.     COM_INTERFACE_ENTRY(IDispatch)
  51.     COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
  52.     COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
  53.     COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
  54.     COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
  55.     COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  56.     COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  57.     COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
  58.     COM_INTERFACE_ENTRY_IMPL(IOleControl)
  59.     COM_INTERFACE_ENTRY_IMPL(IOleObject)
  60.     COM_INTERFACE_ENTRY_IMPL(IPersistStorage)
  61.     COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit)
  62.     COM_INTERFACE_ENTRY(IProvideClassInfo)
  63.     COM_INTERFACE_ENTRY(IProvideClassInfo2)
  64.     COM_INTERFACE_ENTRY(IObjectSafety)
  65. END_COM_MAP()
  66.  
  67. BEGIN_PROPERTY_MAP(CMovieCtl)
  68. //  PROP_PAGE(CLSID_StockColorPage)
  69. //  PROP_ENTRY("Filename", 2, CLSID_NULL)
  70. END_PROPERTY_MAP()
  71.  
  72. BEGIN_MSG_MAP(CMovieCtl)
  73.     MESSAGE_HANDLER(WM_PAINT, OnPaint)
  74.     MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  75.     MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  76. END_MSG_MAP()
  77.  
  78. // IMovieCtl
  79. public:
  80.     STDMETHOD(Stop)();
  81.     STDMETHOD(Reset)();
  82.     STDMETHOD(Pause)();
  83.     void FinalRelease()
  84.     {
  85.         if (m_spVideoWindow)
  86.         {
  87.             // Hide the video window before we reset the owner
  88.             m_spVideoWindow->Visible = FALSE;
  89.             m_spVideoWindow->Owner = NULL;
  90.         }
  91.     }
  92.     STDMETHOD(put_FileName)(/*[in]*/ BSTR newVal);
  93.     STDMETHOD(Play)();
  94.     HRESULT CreateFilterGraph(LPCOLESTR strFile);
  95.     HRESULT OnDraw(ATL_DRAWINFO& di);
  96.  
  97.     STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip)
  98.     {
  99.         HRESULT hr = IOleInPlaceObjectWindowlessImpl<CMovieCtl>::SetObjectRects(prcPos, prcClip);
  100.  
  101.         // Resize the video window if we have one
  102.         if (m_spVideoWindow)
  103.         {
  104.             RECT rc = m_rcPos;
  105.             if (!m_bWndLess)
  106.                 OffsetRect(&rc, -rc.left, -rc.top);
  107.             m_spVideoWindow->SetWindowPosition(rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
  108.         }
  109.  
  110.         return hr;
  111.     }
  112.  
  113. protected:
  114.     IMediaControlPtr    m_spMediaControl;
  115.     IVideoWindowPtr     m_spVideoWindow;
  116. };
  117.  
  118. #endif //__MOVIECTL_H_
  119.