]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/mediactrl_wmp10.cpp
Read TIFF images from top to bottom instead of bottom to top.
[wxWidgets.git] / src / msw / mediactrl_wmp10.cpp
index e1f8e1d08879b71ae95f744f50a50f83398a7844..2cfdb85e260f3a225a9c3c167f9da85376261654 100644 (file)
 #pragma hdrstop
 #endif
 
-//---------------------------------------------------------------------------
-// MediaCtrl include
-//---------------------------------------------------------------------------
+#if wxUSE_MEDIACTRL && wxUSE_ACTIVEX
+
 #include "wx/mediactrl.h"
 
-//---------------------------------------------------------------------------
-// Compilation guard
-//---------------------------------------------------------------------------
-#if wxUSE_MEDIACTRL
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+#endif
 
-//---------------------------------------------------------------------------
-// WX Includes
-//---------------------------------------------------------------------------
-#include "wx/log.h"         // wxLogDebug
 #include "wx/msw/private.h" // user info and wndproc setting/getting
 #include "wx/msw/ole/activex.h" // wxActiveXContainer - COM-specific stuff
 
@@ -681,6 +675,7 @@ public:
     wxSize m_bestSize;              // Actual movie size
 
     bool m_bWasStateChanged;        // See the "introduction"
+    wxEvtHandler* m_evthandler;
 
     friend class wxWMP10MediaEvtHandler;
     DECLARE_DYNAMIC_CLASS(wxWMP10MediaBackend)
@@ -705,7 +700,7 @@ public:
 private:
     wxWMP10MediaBackend *m_amb;
 
-    DECLARE_NO_COPY_CLASS(wxWMP10MediaEvtHandler)
+    wxDECLARE_NO_COPY_CLASS(wxWMP10MediaEvtHandler);
 };
 #endif
 
@@ -729,9 +724,12 @@ wxWMP10MediaBackend::wxWMP10MediaBackend()
 #ifndef WXTEST_ATL
                 m_pAX(NULL),
 #endif
-                m_pWMPPlayer(NULL)
+                m_pWMPPlayer(NULL),
+                m_pWMPSettings(NULL),
+                m_pWMPControls(NULL)
 
 {
+    m_evthandler = NULL;
 }
 
 //---------------------------------------------------------------------------
@@ -745,15 +743,21 @@ wxWMP10MediaBackend::~wxWMP10MediaBackend()
         m_pAX->DissociateHandle();
         delete m_pAX;
 
-        m_ctrl->PopEventHandler(true);
+        if (m_evthandler)
+        {
+            m_ctrl->RemoveEventHandler(m_evthandler);
+            delete m_evthandler;
+        }
 #else
         AtlAxWinTerm();
         _Module.Term();
 #endif
 
         m_pWMPPlayer->Release();
-        m_pWMPSettings->Release();
-        m_pWMPControls->Release();
+        if (m_pWMPSettings)
+            m_pWMPSettings->Release();
+        if (m_pWMPControls)
+            m_pWMPControls->Release();
     }
 }
 
@@ -818,7 +822,8 @@ bool wxWMP10MediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
     m_pAX = new wxActiveXContainer(ctrl, IID_IWMPPlayer, m_pWMPPlayer);
 
     // Connect for events
-    m_ctrl->PushEventHandler(new wxWMP10MediaEvtHandler(this));
+    m_evthandler = new wxWMP10MediaEvtHandler(this);
+    m_ctrl->PushEventHandler(m_evthandler);
 #else
     _Module.Init(NULL, ::GetModuleHandle(NULL));
     AtlAxWinInit();
@@ -829,7 +834,7 @@ bool wxWMP10MediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,
     ::GetClientRect((HWND)ctrl->GetHandle(), &rcClient);
     m_wndView.Create((HWND)ctrl->GetHandle(), rcClient, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
     hr = m_wndView.QueryHost(&spHost);
-    hr = spHost->CreateControl(CComBSTR(_T("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")), m_wndView, 0);
+    hr = spHost->CreateControl(CComBSTR(wxT("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")), m_wndView, 0);
     hr = m_wndView.QueryControl(&m_pWMPPlayer);
 
     if( m_pWMPPlayer->get_settings(&m_pWMPSettings) != 0)
@@ -1451,9 +1456,11 @@ void wxWMP10MediaEvtHandler::OnActiveX(wxActiveXEvent& event)
 }
 
 #endif
-// in source file that contains stuff you don't directly use
-#include "wx/html/forcelnk.h"
-FORCE_LINK_ME(wxmediabackend_wmp10)
+
+// Allow the user code to use wxFORCE_LINK_MODULE() to ensure that this object
+// file is not discarded by the linker.
+#include "wx/link.h"
+wxFORCE_LINK_THIS_MODULE(wxmediabackend_wmp10)
 
 #if 0 // Windows Media Player Mobile 9 hacks
 
@@ -1476,7 +1483,7 @@ bool wxWinCEExecute(const wxString& path, int nShowStyle = SW_SHOWNORMAL)
 {
     WinStruct<SHELLEXECUTEINFO> sei;
     sei.lpFile = path.c_str();
-    sei.lpVerb = _T("open");
+    sei.lpVerb = wxT("open");
     sei.nShow = nShowStyle;
 
     ::ShellExecuteEx(&sei);
@@ -1515,7 +1522,4 @@ bool MyApp::OnInit()
 
 #endif // WMP mobile 9 hacks
 
-//---------------------------------------------------------------------------
-//  End wxMediaCtrl Compilation Guard and this file
-//---------------------------------------------------------------------------
-#endif // wxUSE_MEDIACTRL
+#endif // wxUSE_MEDIACTRL && wxUSE_ACTIVEX