//---------------------------------------------------------------------------
#if wxUSE_MEDIACTRL
+#include "wx/dcclient.h"
+
//---------------------------------------------------------------------------
// Externals (somewhere in src/msw/app.cpp)
//---------------------------------------------------------------------------
IMediaControl* m_pMC;
IMediaEvent* m_pME;
IMediaPosition* m_pMS;
+ bool m_bVideo;
wxAMMediaThread* m_pThread;
//
// Connect Events
//
-//TODO: Greg Hazel reports problems with this... but win2k seems fine on mine...
-// m_ctrl->Connect(m_ctrl->GetId(), wxEVT_ERASE_BACKGROUND,
-// wxEraseEventHandler(wxAMMediaEvtHandler::OnEraseBackground),
-// NULL, (wxEvtHandler*) this);
- m_ctrl->Connect(m_ctrl->GetId(), wxEVT_PAINT,
- wxPaintEventHandler(wxAMMediaEvtHandler::OnPaint),
+ //TODO: Greg Hazel reports problems with this... but win2k seems fine on mine...
+ //-------------------------------------------------------------------------------
+ // My problem with this was only with a previous patch, probably the third rewrite
+ // fixed it as a side-effect. In fact, the erase background style of drawing not
+ // only works now, but is much better than paint-based updates (the paint event
+ // handler flickers if the wxMediaCtrl shares a sizer with another child window,
+ // or is on a notebook)
+ // - Greg Hazel
+ m_ctrl->Connect(m_ctrl->GetId(), wxEVT_ERASE_BACKGROUND,
+ wxEraseEventHandler(wxAMMediaEvtHandler::OnEraseBackground),
NULL, (wxEvtHandler*) this);
+ //m_ctrl->Connect(m_ctrl->GetId(), wxEVT_PAINT,
+ // wxPaintEventHandler(wxAMMediaEvtHandler::OnPaint),
+ // NULL, (wxEvtHandler*) this);
//
// As noted below, we need to catch the Top Level Window's
wxASSERT(false);
}
+ if(m_bestSize.x == 0 && m_bestSize.y == 0)
+ m_bVideo = false;
+ else
+ m_bVideo = true;
+
//
// Force the parent window of this control to recalculate
// the size of this if sizers are being used
void wxAMMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
int w, int h)
{
- if(m_pVMC)
+ if(m_pVMC && m_bVideo)
{
RECT srcRect, destRect;
srcRect.top = 0; srcRect.left = 0;
srcRect.bottom = m_bestSize.y; srcRect.right = m_bestSize.x;
+ //it happens.
+ if (w < 0)
+ {
+ w = 0;
+ }
+ if (h < 0)
+ {
+ h = 0;
+ }
+
//position in window client coordinates to display and stretch to
destRect.top = 0; destRect.left = 0;
destRect.bottom = h; destRect.right = w;
//---------------------------------------------------------------------------
void wxAMMediaBackend::OnStop()
{
- //send the event to our child
- wxMediaEvent theEvent(wxEVT_MEDIA_STOP, m_ctrl->GetId());
- m_ctrl->ProcessEvent(theEvent);
+ //send the event to our child
+ wxMediaEvent theEvent(wxEVT_MEDIA_STOP, m_ctrl->GetId());
+ m_ctrl->ProcessEvent(theEvent);
- //if the user didn't veto it, stop the stream
- if (theEvent.IsAllowed())
- {
- //Interestingly enough, DirectShow does not actually stop
- //the filters - even when it reaches the end!
- wxVERIFY( Stop() );
-
- //send the event to our child
- wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
- m_ctrl->GetId());
- m_ctrl->ProcessEvent(theEvent);
- }
+ //if the user didn't veto it, stop the stream
+ if (theEvent.IsAllowed())
+ {
+ //Interestingly enough, DirectShow does not actually stop
+ //the filters - even when it reaches the end!
+ wxVERIFY( Stop() );
+
+ //send the event to our child
+ wxMediaEvent theEvent(wxEVT_MEDIA_FINISHED,
+ m_ctrl->GetId());
+ m_ctrl->ProcessEvent(theEvent);
+ }
}
//---------------------------------------------------------------------------
void wxAMMediaEvtHandler::OnEraseBackground(wxEraseEvent& evt)
{
wxAMMediaBackend* pThis = (wxAMMediaBackend*) this;
- if(pThis->m_pVMC)
+ if(pThis->m_pVMC && pThis->m_bVideo)
{
//TODO: Use wxClientDC?
HDC hdc = ::GetDC((HWND)pThis->m_ctrl->GetHandle());
if( pThis->m_pVMC->RepaintVideo((HWND)pThis->m_ctrl->GetHandle(),
- hdc) != 0 )
+ hdc) != 0 )
{
wxASSERT(false);
- }
+ }
::ReleaseDC((HWND)pThis->m_ctrl->GetHandle(), hdc);
}
else
+ {
evt.Skip();
+ }
}
//---------------------------------------------------------------------------
{
wxAMMediaBackend* pThis = (wxAMMediaBackend*) this;
wxPaintDC dc(pThis->m_ctrl);
- if( pThis->m_pVMC->RepaintVideo((HWND)pThis->m_ctrl->GetHandle(),
- (HDC)dc.GetHDC()) != 0 )
+ if( pThis->m_pVMC && pThis->m_bVideo)
{
- wxASSERT(false);
+ if( pThis->m_pVMC->RepaintVideo((HWND)pThis->m_ctrl->GetHandle(),
+ (HDC)dc.GetHDC()) != 0 )
+ {
+ wxASSERT(false);
+ }
}
}