X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e4db172a3b318df9aff178eb6c5da149d56e0859..43f4e852a1b2ac37c3db6a2b87315192ac549191:/src/msw/mediactrl_wmp10.cpp diff --git a/src/msw/mediactrl_wmp10.cpp b/src/msw/mediactrl_wmp10.cpp index 2dc26fdbdf..818ae20f2d 100644 --- a/src/msw/mediactrl_wmp10.cpp +++ b/src/msw/mediactrl_wmp10.cpp @@ -28,7 +28,7 @@ // is about to be played - and if the user didn't change the state of the // media (m_bWasStateChanged), when set it back to the stop state. // -// The ActiveX control itself is particularily stubborn, calling +// The ActiveX control itself is particularly stubborn, calling // IOleInPlaceSite::OnPosRectChange every file change trying to set itself // to something different then what we told it to before. // @@ -50,7 +50,7 @@ #pragma hdrstop #endif -#if wxUSE_MEDIACTRL +#if wxUSE_MEDIACTRL && wxUSE_ACTIVEX #include "wx/mediactrl.h" @@ -675,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) @@ -699,7 +700,7 @@ public: private: wxWMP10MediaBackend *m_amb; - DECLARE_NO_COPY_CLASS(wxWMP10MediaEvtHandler) + wxDECLARE_NO_COPY_CLASS(wxWMP10MediaEvtHandler); }; #endif @@ -723,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; } //--------------------------------------------------------------------------- @@ -739,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(); } } @@ -812,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(); @@ -823,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) @@ -850,7 +861,7 @@ bool wxWMP10MediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, IWMPPlayer2* pWMPPlayer2; // Only 2 has windowless video and stretchtofit if(m_pWMPPlayer->QueryInterface(IID_IWMPPlayer2, (void**)&pWMPPlayer2) == 0) { - // We don't check errors here as these arn't particularily important + // We don't check errors here as these arn't particularly important // and may not be implemented (i.e. stretchToFit on CE) pWMPPlayer2->put_windowlessVideo(VARIANT_TRUE); pWMPPlayer2->put_stretchToFit(VARIANT_TRUE); @@ -1445,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 @@ -1459,7 +1472,7 @@ FORCE_LINK_ME(wxmediabackend_wmp10) // you playing a file through WMP. // // Here are those hacks. They do indeed "work" as expected - just call -// SendMessage with one of those myterious values layed out in +// SendMessage with one of those myterious values laid out in // Peter Foot's Friday, May 21, 2004 Blog Post on the issue. // (He says they are in a registery section entitled "Pendant Bus") // @@ -1470,7 +1483,7 @@ bool wxWinCEExecute(const wxString& path, int nShowStyle = SW_SHOWNORMAL) { WinStruct sei; sei.lpFile = path.c_str(); - sei.lpVerb = _T("open"); + sei.lpVerb = wxT("open"); sei.nShow = nShowStyle; ::ShellExecuteEx(&sei); @@ -1509,4 +1522,4 @@ bool MyApp::OnInit() #endif // WMP mobile 9 hacks -#endif // wxUSE_MEDIACTRL +#endif // wxUSE_MEDIACTRL && wxUSE_ACTIVEX