]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/mediactrl_am.cpp
correct access for virtual
[wxWidgets.git] / src / msw / mediactrl_am.cpp
index 52644f1bc856653fb890f129d96d958832c4774e..be49d39044e3577c92dd88b4dbadece4da2a4408 100644 (file)
@@ -47,7 +47,7 @@
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-#pragma hdrstop
+    #pragma hdrstop
 #endif
 
 // disable "cast truncates constant value" for VARIANT_BOOL values
 #pragma warning (disable:4310)
 #endif
 
-//---------------------------------------------------------------------------
-// MediaCtrl include
-//---------------------------------------------------------------------------
+#if wxUSE_MEDIACTRL && wxUSE_ACTIVEX
+
 #include "wx/mediactrl.h"
 
-//---------------------------------------------------------------------------
-// Compilation guard
-//---------------------------------------------------------------------------
-#if wxUSE_MEDIACTRL
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+    #include "wx/dcclient.h"
+    #include "wx/timer.h"
+    #include "wx/math.h"        // log10 & pow
+    #include "wx/stopwatch.h"
+#endif
 
-//---------------------------------------------------------------------------
-// WX Includes
-//---------------------------------------------------------------------------
-#include "wx/log.h"         // wxLogDebug
-#include "wx/math.h"        // log10 & pow
 #include "wx/msw/private.h" // user info and wndproc setting/getting
-#include "wx/dcclient.h"
-#include "wx/timer.h"
 #include "wx/dynlib.h"
-#include "wx/stopwatch.h"
 
 //---------------------------------------------------------------------------
 //  wxActiveXContainer - includes all the COM-specific stuff we need
@@ -1572,11 +1566,12 @@ wxString wxAMMediaBackend::GetErrorString(HRESULT hrdsv)
 wxAMMediaBackend::wxAMMediaBackend()
                  :m_pAX(NULL),
 #ifdef __WXWINCE__
-                  m_pWMP(NULL)
+                  m_pWMP(NULL),
 #else
                   m_pAM(NULL),
-                  m_pMP(NULL)
+                  m_pMP(NULL),
 #endif
+                  m_bestSize(wxDefaultSize)
 {
 }
 
@@ -1797,6 +1792,7 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
         return false;
     }
 
+    m_bestSize = wxDefaultSize;
     return true;
 }
 
@@ -1810,10 +1806,6 @@ bool wxAMMediaBackend::DoLoad(const wxString& location)
 //---------------------------------------------------------------------------
 void wxAMMediaBackend::FinishLoad()
 {
-    // Get the original video size
-    GetAM()->get_ImageSourceWidth((long*)&m_bestSize.x);
-    GetAM()->get_ImageSourceHeight((long*)&m_bestSize.y);
-
     NotifyMovieLoaded();
 }
 
@@ -2148,7 +2140,22 @@ void wxAMMediaBackend::DoGetDownloadProgress(wxLongLong* pLoadProgress,
 //---------------------------------------------------------------------------
 wxSize wxAMMediaBackend::GetVideoSize() const
 {
-    return m_bestSize;
+    if (m_bestSize == wxDefaultSize)
+    {
+        wxAMMediaBackend* self = wxConstCast(this, wxAMMediaBackend);
+        long w = 0;
+        long h = 0;
+
+        self->GetAM()->get_ImageSourceWidth(&w);
+        self->GetAM()->get_ImageSourceHeight(&h);
+
+        if (w != 0 && h != 0)
+            self->m_bestSize.Set(w, h);
+        else
+            return wxSize(0,0);
+    }
+
+   return m_bestSize;
 }
 
 //---------------------------------------------------------------------------
@@ -2263,7 +2270,4 @@ void wxAMMediaEvtHandler::OnActiveX(wxActiveXEvent& event)
 #include "wx/html/forcelnk.h"
 FORCE_LINK_ME(wxmediabackend_am)
 
-//---------------------------------------------------------------------------
-//  End wxMediaCtrl Compilation Guard and this file
-//---------------------------------------------------------------------------
-#endif // wxUSE_MEDIACTRL
+#endif // wxUSE_MEDIACTRL && wxUSE_ACTIVEX