[xiph-commits] r16937 - trunk/oggdsf/src/lib/plugin/AxPlayer

cristianadam at svn.xiph.org cristianadam at svn.xiph.org
Sun Feb 28 13:51:41 PST 2010


Author: cristianadam
Date: 2010-02-28 13:51:41 -0800 (Sun, 28 Feb 2010)
New Revision: 16937

Modified:
   trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj
   trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl
   trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.vcproj
   trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp
   trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp
   trunk/oggdsf/src/lib/plugin/AxPlayer/Guid.h
   trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp
   trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h
Log:
<video> tag works now also in Internet Explorer standards mode.

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer-2005.vcproj	2010-02-28 21:51:41 UTC (rev 16937)
@@ -214,6 +214,7 @@
 			UseOfATL="1"
 			ATLMinimizesCRunTimeLibraryUsage="false"
 			CharacterSet="1"
+			WholeProgramOptimization="1"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -243,6 +244,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="2"
+				WholeProgramOptimization="true"
 				AdditionalIncludeDirectories="&quot;Generated Files&quot;;res;..\..\helper"
 				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_BIND_TO_CURRENT_CRT_VERSION;WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB"
 				ExceptionHandling="2"
@@ -310,6 +312,7 @@
 			UseOfATL="1"
 			ATLMinimizesCRunTimeLibraryUsage="false"
 			CharacterSet="1"
+			WholeProgramOptimization="1"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -338,6 +341,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="2"
+				WholeProgramOptimization="true"
 				AdditionalIncludeDirectories="&quot;Generated Files&quot;;res;..\..\helper\"
 				PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_BIND_TO_CURRENT_CRT_VERSION;WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB"
 				ExceptionHandling="2"

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.idl	2010-02-28 21:51:41 UTC (rev 16937)
@@ -28,6 +28,30 @@
 interface IHTMLEventsSink : IDispatch{
 };
 [
+	object,
+	uuid(12804362-B793-4237-89BF-AAB42EF969EA),
+	nonextensible,
+	helpstring("IEmbeddedAxEventsSink Interface"),
+	pointer_default(unique)
+]
+interface IEmbeddedAxEventsSink : IUnknown{
+
+    [helpstring("method OnLeftButtonDown")] HRESULT OnLeftButtonDown(LONG x, LONG y);
+    [helpstring("method OnEmbeddedDraw")] HRESULT OnEmbeddedDraw(RECT rect, HDC hdc);
+};
+[
+	object,
+	uuid(C71190BD-F187-4187-8136-820B40C6F629),
+	nonextensible,
+	helpstring("IEmbeddedAx Interface"),
+	pointer_default(unique)
+]
+interface IEmbeddedAx : IUnknown{
+    [helpstring("method SetEventsSink")] HRESULT SetEventsSink(IUnknown* events);
+    [helpstring("method EmbeddedRefresh")] HRESULT EmbeddedRefresh();
+};
+
+[
 	uuid(4856ADA6-564F-41B8-ACAA-E98ABD004A84),
 	version(1.0),
 	helpstring("AxPlayer 1.0 Type Library")

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.vcproj
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.vcproj	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/AxPlayer.vcproj	2010-02-28 21:51:41 UTC (rev 16937)
@@ -209,6 +209,7 @@
 			UseOfATL="1"
 			ATLMinimizesCRunTimeLibraryUsage="false"
 			CharacterSet="1"
+			WholeProgramOptimization="1"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -238,6 +239,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="2"
+				WholeProgramOptimization="true"
 				AdditionalIncludeDirectories="&quot;Generated Files&quot;;res;..\..\helper"
 				PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB"
 				ExceptionHandling="2"
@@ -302,6 +304,7 @@
 			UseOfATL="1"
 			ATLMinimizesCRunTimeLibraryUsage="false"
 			CharacterSet="1"
+			WholeProgramOptimization="1"
 			>
 			<Tool
 				Name="VCPreBuildEventTool"
@@ -330,6 +333,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="2"
+				WholeProgramOptimization="true"
 				AdditionalIncludeDirectories="&quot;Generated Files&quot;;res;..\..\helper\"
 				PreprocessorDefinitions="WIN32;_WINDOWS;NDEBUG;_USRDLL;_MERGE_PROXYSTUB"
 				ExceptionHandling="2"

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/DShowVideoPlayer.cpp	2010-02-28 21:51:41 UTC (rev 16937)
@@ -111,38 +111,17 @@
 
 HRESULT DShowVideoPlayer::Draw(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject)
 {
-//    CRect rect(rcBounds.left, rcBounds.top, rcBounds.left + m_width, rcBounds.top + m_height);
     CRect rect(rcBounds);
 
     HRESULT hr = S_OK;
     try
     {
-        CComPtr<IDirectDrawSurface> destSurface;
-
-        destSurface = reinterpret_cast<IDirectDrawSurface*>(pvDrawObject);
-
-        DDSURFACEDESC descriptor = {};
-        descriptor.dwSize = sizeof(DDSURFACEDESC);
-
-        CHECK_HR(destSurface->GetSurfaceDesc(&descriptor));
-
-        LOG(logDEBUG4) << __FUNCTIONW__ << " DirectDrawSurface: " << destSurface;
-        LOG(logDEBUG4) << "SurfaceDescFlags: " << DDrawUtil::GetSurfaceDescFlags(descriptor.dwFlags).c_str();
-        LOG(logDEBUG4) << "Pixel Format: " << std::endl
-            << "\tSize: " << descriptor.ddpfPixelFormat.dwSize << std::endl
-            << "\tFlags: " << DDrawUtil::GetPixelFormatFlags(descriptor.ddpfPixelFormat.dwFlags).c_str() << std::endl
-            << "\tFourCC: " << descriptor.ddpfPixelFormat.dwFourCC << std::endl
-            << "\tRGBBitCount: " << descriptor.ddpfPixelFormat.dwRGBBitCount << std::endl;
-
         if (m_backBuffer)
         {
             // Use a third buffer to scale the picture
             CComPtr<IDirectDrawSurface7> scaledSurface = GetScalingSurface(CSize(rect.Width(), rect.Height()));
             CHECK_HR(scaledSurface->Blt(NULL, m_backBuffer, NULL, DDBLT_WAIT, NULL));
 
-            HDC destDC;
-            CHECK_HR(destSurface->GetDC(&destDC));
-
             HDC scaledDC;
             CHECK_HR(scaledSurface->GetDC(&scaledDC));
 
@@ -171,10 +150,9 @@
                 break;
             }
 
-            ::BitBlt(destDC, rect.left, rect.top, rect.Width(), rect.Height(), scaledDC, 0, 0, SRCCOPY);
+            ::BitBlt(hdc, rect.left, rect.top, rect.Width(), rect.Height(), scaledDC, 0, 0, SRCCOPY);
 
             CHECK_HR(scaledSurface->ReleaseDC(scaledDC));
-            CHECK_HR(destSurface->ReleaseDC(destDC));
         }
     }
     catch (const CAtlException& except)

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/FilterGraph.cpp	2010-02-28 21:51:41 UTC (rev 16937)
@@ -62,6 +62,8 @@
 {
     m_videoUrl = videoUrl;
 
+    LOG(logINFO) << __FUNCTIONW__ << " Building graph for: \"" << m_videoUrl << "\"";
+
     try
     {
         CHECK_HR(m_graphBuilder.CoCreateInstance(CLSID_FilterGraph));
@@ -75,6 +77,8 @@
 
         CHECK_HR(m_graphBuilder.QueryInterface(&m_mediaControl));
         CHECK_HR(m_graphBuilder.QueryInterface(&m_mediaEvent));
+
+        LOG(logINFO) << __FUNCTIONW__ << " Graph was successfully build.";
     }
     catch (const CAtlException& /*except*/)
     {

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/Guid.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/Guid.h	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/Guid.h	2010-02-28 21:51:41 UTC (rev 16937)
@@ -76,6 +76,14 @@
         Data4[7] = other.Data4[7];
     }
 
+    static Guid Create()
+    {
+        Guid guid;
+        ::CoCreateGuid(&guid);
+
+        return guid;
+    }
+
     template <class T>
     T strToNum(const string &inputString, std::ios_base &(*f)(std::ios_base&) = std::dec)
     {

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.cpp	2010-02-28 21:51:41 UTC (rev 16937)
@@ -34,6 +34,7 @@
 #include "VideoTagBehavior.h"
 #include "common/util.h"
 #include <ddraw.h>
+#include "Guid.h"
 
 // VideoTagBehavior
 namespace {
@@ -45,21 +46,39 @@
 
 VideoTagBehavior::VideoTagBehavior() : 
 m_width(320),
-m_height(240)
+m_height(240),
+m_factoryObject(false),
+m_standardsMode(true)
 {
+    m_sizeExtent.cx = 0;
+    m_sizeExtent.cy = 0;
+
     LOG(logDEBUG) << this << ": " << __FUNCTIONW__; 
 }
 
+VideoTagBehavior::~VideoTagBehavior()
+{
+    LOG(logDEBUG) << this << ": " << __FUNCTIONW__;
+}
+
+
 HRESULT __stdcall VideoTagBehavior::Init(IElementBehaviorSite* pBehaviorSite)
 {
+    LOG(logDEBUG) << __FUNCTIONW__;
+
     HRESULT hr = S_OK;
 
-    m_site = pBehaviorSite;
-    hr = m_site->QueryInterface(&m_omSite);
-    hr = m_site->QueryInterface(&m_paintSite);
+    try
+    {
+        m_site = pBehaviorSite;
+        CHECK_HR(m_site->QueryInterface(&m_omSite));
+        CHECK_HR(m_site->QueryInterface(&m_paintSite));
+    }
+    catch(const CAtlException& except)
+    {
+        hr = except.m_hr;
+    }
 
-    LOG(logDEBUG) << __FUNCTIONW__;
-
     return hr;
 }
 
@@ -75,10 +94,24 @@
         {
         case BEHAVIOREVENT_CONTENTREADY: 
             // End tag of element has been parsed (we can get at attributes)
+            {
+                CHECK_HR(m_site->GetElement(&m_element));
+
+                m_embeddedAxGuid = Guid::Create().ToString().c_str();
+
+                CString embeddedAxText;
+                embeddedAxText.Format(
+                    L"<object id=\"%s\""
+                        L"classid=\"clsid:7cc95ae6-c1fa-40cc-ab17-3e91da2f77ca\">"
+                    L"</object>", m_embeddedAxGuid);
+
+                CHECK_HR(m_element->put_innerHTML(CComBSTR(embeddedAxText)));
+            }
             break;
         case BEHAVIOREVENT_DOCUMENTREADY:	
             // HTML document has been parsed (we can get at the document object model)
             {
+                m_element = 0;
                 CHECK_HR(m_site->GetElement(&m_element));
                 
                 CComPtr<IHTMLStyle> style;
@@ -97,6 +130,8 @@
                 m_videoPlayer.InitializePlaybackThread();
 
                 CHECK_HR(HTMLEvents::DispEventAdvise(m_element));
+
+                AcquireEmbeddedAx();
             }
             break;
         }
@@ -111,6 +146,8 @@
 
 HRESULT __stdcall VideoTagBehavior::Detach()
 {
+    LOG(logDEBUG) << this << ": " << __FUNCTIONW__;
+
     m_videoPlayer.StopPlaybackThread();
     m_videoPlayer.DestroyWindow();
 
@@ -120,7 +157,7 @@
 HRESULT __stdcall VideoTagBehavior::FindBehavior(BSTR bstrBehavior, BSTR bstrBehaviorUrl, 
                                                  IElementBehaviorSite* pSite, IElementBehavior** ppBehavior)
 {
-    LOG(logDEBUG) << __FUNCTIONW__ << " bstrBehavior: " << bstrBehavior;
+    LOG(logDEBUG) << this << " " << __FUNCTIONW__ << " bstrBehavior: " << bstrBehavior;
 
     if (bstrBehavior == 0)
     {
@@ -158,9 +195,19 @@
 
     LOG(logDEBUG) << this << ": " << __FUNCTIONW__;
 
+    m_factoryObject = true;
+
     return S_OK;
 }
 
+HWND VideoTagBehavior::Create( HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName /*= NULL*/, 
+                              DWORD dwStyle /*= 0*/, DWORD dwExStyle /*= 0*/, _U_MENUorID MenuOrID /*= 0U*/, 
+                              LPVOID lpCreateParam /*= NULL*/ )
+{
+    return CComControl<VideoTagBehavior>::Create(hWndParent, rect, szWindowName, dwStyle, 
+        dwExStyle, MenuOrID, lpCreateParam);
+}
+
 HRESULT __stdcall VideoTagBehavior::Resolve(BSTR bstrNamespace, BSTR bstrTagName, BSTR bstrAttrs, 
                                             IElementNamespace* pNamespace)
 {
@@ -225,14 +272,10 @@
     pInfo->lFlags = 
         HTMLPAINTER_NOSAVEDC | 
         HTMLPAINTER_SUPPORTS_XFORM | 
-        HTMLPAINTER_OVERLAY |
-        HTMLPAINTER_SURFACE |
         HTMLPAINTER_HITTEST;
 
     pInfo->lZOrder = HTMLPAINT_ZORDER_REPLACE_ALL;
 
-    pInfo->iidDrawObject = IID_IDirectDrawSurface;
-
     pInfo->rcExpand.left = 0;
     pInfo->rcExpand.top = 0;
     pInfo->rcExpand.right = 0;
@@ -241,12 +284,35 @@
     return S_OK;
 }
 
+
+HRESULT __stdcall VideoTagBehavior::OnEmbeddedDraw(RECT rect, HDC hdc)
+{
+    HRESULT hr = m_videoPlayer.Draw(rect, rect, 0, hdc, 0);
+    return hr;
+}
+
 HRESULT __stdcall VideoTagBehavior::Draw(RECT rcBounds, RECT rcUpdate, LONG lDrawFlags, HDC hdc, LPVOID pvDrawObject)
 {
+    // This is called only in Quirks mode
+    m_standardsMode = false;
+
     HRESULT hr = m_videoPlayer.Draw(rcBounds, rcUpdate, lDrawFlags, hdc, pvDrawObject);
     return hr;
 }
 
+HRESULT VideoTagBehavior::OnDraw(ATL_DRAWINFO& di)
+{
+    RECT& rc = *(RECT*)di.prcBounds;
+
+    if (m_embeddedAxEventsSink)
+    {
+        m_embeddedAxEventsSink->OnEmbeddedDraw(rc, di.hdcDraw);
+    }
+
+    return S_OK;
+}
+
+
 HRESULT __stdcall VideoTagBehavior::HitTestPoint(POINT pt, BOOL *pbHit, LONG *plPartID)
 {
     *pbHit = TRUE;
@@ -332,12 +398,27 @@
 
 void VideoTagBehavior::Refresh()
 {
-    if (m_paintSite)
+    if (m_standardsMode)
     {
+        CComQIPtr<IEmbeddedAx> embeddedAx = m_embeddedAxElement;
+        if (embeddedAx)
+        {
+            embeddedAx->EmbeddedRefresh();
+        }
+    }
+    else if (m_paintSite)
+    {
         m_paintSite->InvalidateRect(0);
     }
 }
 
+
+HRESULT __stdcall VideoTagBehavior::EmbeddedRefresh()
+{
+    FireViewChange();
+    return S_OK;
+}
+
 void VideoTagBehavior::MovieSize(const CSize& movieSize)
 {
     m_width = movieSize.cx;
@@ -351,6 +432,12 @@
         CHECK_HR(style->put_pixelWidth(m_width));
         CHECK_HR(style->put_pixelHeight(m_height));
 
+        style = 0;
+
+        CHECK_HR(m_embeddedAxElement->get_style(&style));
+        CHECK_HR(style->put_pixelWidth(m_width));
+        CHECK_HR(style->put_pixelHeight(m_height));
+
         m_videoPlayer.SetWidth(m_width);
         m_videoPlayer.SetHeight(m_height);
     }
@@ -416,3 +503,73 @@
 
     return isRelative;
 }
+
+HRESULT __stdcall VideoTagBehavior::SetClientSite(IOleClientSite* pSite)
+{
+    m_oleClientSite = pSite;
+    return CComControlBase::IOleObject_SetClientSite(pSite);
+}
+
+void VideoTagBehavior::AcquireEmbeddedAx()
+{
+    CComPtr<IDispatch> disp;
+    CHECK_HR(m_element->get_children(&disp));
+
+    CComQIPtr<IHTMLElementCollection> elementCollectionList = disp;
+    disp = 0;
+
+    long childrenCount = 0;
+    CHECK_HR(elementCollectionList->get_length(&childrenCount));
+    ATLASSERT(childrenCount == 1 && "We should have only one child");
+
+    for (long i = 0; i < childrenCount; ++i)
+    {
+        CComVariant itemId(m_embeddedAxGuid);
+        CComVariant item(i);
+        CHECK_HR(elementCollectionList->item(itemId, item, &disp));
+
+        CComQIPtr<IHTMLElement> element = disp;
+        disp = 0;
+
+        if (!element)
+        {
+            continue;
+        }
+
+        m_embeddedAxElement = element;
+
+        // Configure the communication between the <video> tag and the
+        // embedded ActiveX
+        CComQIPtr<IEmbeddedAx> embeddedAx = element;
+        CComQIPtr<IEmbeddedAxEventsSink> embeddedAxEventsSink = this;
+        
+        embeddedAx->SetEventsSink(embeddedAxEventsSink);
+    }
+}
+
+LRESULT VideoTagBehavior::OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/)
+{
+    if (m_embeddedAxEventsSink)
+    {
+        m_embeddedAxEventsSink->OnLeftButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
+    }
+
+    return 0;
+}
+
+HRESULT __stdcall VideoTagBehavior::OnLeftButtonDown(LONG /*x*/, LONG /*y*/)
+{
+    OnClick();
+    return 0;
+}
+
+HRESULT __stdcall VideoTagBehavior::SetEventsSink(IUnknown *events)
+{
+    if (!events)
+    {
+        return E_POINTER;
+    }
+
+    HRESULT hr = events->QueryInterface(&m_embeddedAxEventsSink);
+    return hr;
+}

Modified: trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h
===================================================================
--- trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h	2010-02-26 09:49:46 UTC (rev 16936)
+++ trunk/oggdsf/src/lib/plugin/AxPlayer/VideoTagBehavior.h	2010-02-28 21:51:41 UTC (rev 16937)
@@ -64,11 +64,44 @@
     public IElementNamespaceFactoryCallback,
     public IHTMLPainter,
     public HTMLEvents,
-    public DShowVideoPlayerCallback
+    public DShowVideoPlayerCallback,
+    // Regular ActiveX
+    public IOleControlImpl<VideoTagBehavior>,
+    public IOleObjectImpl<VideoTagBehavior>,
+    public IOleInPlaceActiveObjectImpl<VideoTagBehavior>,
+    public IViewObjectExImpl<VideoTagBehavior>,
+    public IOleInPlaceObjectWindowlessImpl<VideoTagBehavior>,
+    public IQuickActivateImpl<VideoTagBehavior>,
+    public CComControl<VideoTagBehavior>,
+    public IEmbeddedAxEventsSink,
+    public IEmbeddedAx
 {
 public:
 	VideoTagBehavior();
+    virtual ~VideoTagBehavior();
 
+    // ActiveX
+    DECLARE_OLEMISC_STATUS(
+        OLEMISC_RECOMPOSEONRESIZE |
+        OLEMISC_CANTLINKINSIDE |
+        OLEMISC_INSIDEOUT |
+        OLEMISC_ACTIVATEWHENVISIBLE |
+        OLEMISC_SETCLIENTSITEFIRST)
+
+    BEGIN_PROP_MAP(VideoTagBehavior)
+        PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
+        PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
+        // Example entries
+        // PROP_ENTRY_TYPE("Property Name", dispid, clsid, vtType)
+        // PROP_PAGE(CLSID_StockColorPage)
+    END_PROP_MAP()
+
+    HWND Create(HWND hWndParent, _U_RECT rect, LPCTSTR szWindowName = NULL,
+        DWORD dwStyle = 0, DWORD dwExStyle = 0,
+        _U_MENUorID MenuOrID = 0U, LPVOID lpCreateParam = NULL);
+
+    HRESULT OnDraw(ATL_DRAWINFO& di);
+
     DECLARE_REGISTRY_RESOURCEID(IDR_VIDEOTAGBEHAVIOR)
 
     DECLARE_NOT_AGGREGATABLE(VideoTagBehavior)
@@ -85,6 +118,18 @@
         COM_INTERFACE_ENTRY(IElementNamespaceFactory)
         COM_INTERFACE_ENTRY(IElementNamespaceFactoryCallback)
         COM_INTERFACE_ENTRY(IHTMLPainter)
+        // ActiveX
+        COM_INTERFACE_ENTRY(IViewObjectEx)
+        COM_INTERFACE_ENTRY(IViewObject2)
+        COM_INTERFACE_ENTRY(IViewObject)
+        COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
+        COM_INTERFACE_ENTRY(IOleInPlaceObject)
+        COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
+        COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
+        COM_INTERFACE_ENTRY(IOleControl)
+        COM_INTERFACE_ENTRY(IOleObject)
+        COM_INTERFACE_ENTRY(IEmbeddedAxEventsSink)
+        COM_INTERFACE_ENTRY(IEmbeddedAx)
     END_COM_MAP()
 
     BEGIN_CONNECTION_POINT_MAP(VideoTagBehavior)
@@ -95,6 +140,12 @@
         SINK_ENTRY_EX(1, DIID_HTMLElementEvents, DISPID_HTMLDOCUMENTEVENTS_ONCLICK, OnClick)
     END_SINK_MAP()
 
+    BEGIN_MSG_MAP(VideoTagBehavior)
+        MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
+        CHAIN_MSG_MAP(CComControl<VideoTagBehavior>)
+        DEFAULT_REFLECTION_HANDLER()
+    END_MSG_MAP()
+
 	DECLARE_PROTECT_FINAL_CONSTRUCT()
 
 	HRESULT FinalConstruct();
@@ -142,8 +193,26 @@
     // IObjectWithSite
     virtual HRESULT __stdcall SetSite(IUnknown *pUnkSite);
 
+    HRESULT __stdcall SetClientSite(IOleClientSite* pSite);
+
+    // IViewObjectEx
+    DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
+
+    // ActiveX Windows Events, received only by the embedded control
+    LRESULT OnLButtonDown(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/);
+
+    // IEmbeddedAxEventsSink
+    virtual HRESULT __stdcall OnLeftButtonDown(LONG x, LONG y);
+    virtual HRESULT __stdcall OnEmbeddedDraw(RECT rect, HDC hdc);
+
+    // IEmbeddedAx
+    virtual HRESULT __stdcall SetEventsSink(IUnknown *events);
+    virtual HRESULT __stdcall EmbeddedRefresh();
+
+
 private:
     void ParseElementAttributes();
+    void AcquireEmbeddedAx();
     
     CString GetSiteURL();
     bool IsRelativeURL(const CString& url);
@@ -155,12 +224,20 @@
     CComPtr<IHTMLElement> m_element;
     CComPtr<IOleClientSite> m_oleClientSite;
 
+    CString m_embeddedAxGuid;
+    CComPtr<IHTMLElement> m_embeddedAxElement;
+
+    CComPtr<IEmbeddedAxEventsSink> m_embeddedAxEventsSink;
+
     int m_width;
     int m_height;
 
     CSize m_movieSize;
 
     DShowVideoPlayer m_videoPlayer;
+    
+    bool m_factoryObject;
+    bool m_standardsMode;
 };
 
 OBJECT_ENTRY_AUTO(__uuidof(VideoTagBehavior), VideoTagBehavior)



More information about the commits mailing list