|
// AviPlayerWnd.cpp : implementation file
//
#include "stdafx.h"
#include "aviframes.h"
#include "AviPlayerWnd.h"
#include "AviPlayer.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAviPlayerWnd
IMPLEMENT_DYNAMIC(CAviPlayerWnd, CWnd)
CAviPlayerWnd::CAviPlayerWnd( CAviPlayer *pAviPlayer )
{
m_pAviPlayer = pAviPlayer;
}
CAviPlayerWnd::~CAviPlayerWnd()
{
}
BEGIN_MESSAGE_MAP(CAviPlayerWnd, CWnd)
//{{AFX_MSG_MAP(CAviPlayerWnd)
ON_WM_TIMER()
ON_WM_CREATE()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
bool CAviPlayerWnd::Create(
CWnd * pWndParent,
UINT nDlgCtrlID, // = AFX_IDW_PANE_FIRST
CRect rc, // = CRect( 0,0,0,0 )
DWORD dwStyle, // = WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_HSCROLL|WS_VSCROLL
DWORD dwStyleEx // = 0L
)
{
LPCTSTR strClass =
::AfxRegisterWndClass(
CS_DBLCLKS,
::LoadCursor(NULL, IDC_ARROW),
NULL,
NULL
);
if( strClass == NULL )
{
ASSERT( FALSE );
return false;
}
if( ! CreateEx(
dwStyleEx,
strClass,
_T(""),
dwStyle,
rc.left, rc.top, rc.Width(), rc.Height(),
pWndParent->GetSafeHwnd(),
NULL,
NULL
)
)
{
ASSERT( FALSE );
return false;
}
SetDlgCtrlID( nDlgCtrlID );
return true;
}
/////////////////////////////////////////////////////////////////////////////
// CAviPlayerWnd message handlers
void CAviPlayerWnd::OnTimer(UINT nIDEvent)
{
if( nIDEvent == 1 )
{
if( m_pAviPlayer == NULL )
return;
BOOL bTempPause = m_pAviPlayer->GetTempPause();
if( bTempPause ){
m_nTimerStart = GetTickCount();
return;
}
int nTimerSpeed = m_pAviPlayer->GetTimerSpeed();
DWORD nCurrentTimePlayed = 0;
DWORD nCurrentTimeNeeded = 0;
int i = 0;
do
{
i++;
m_pAviPlayer->NextFrame();
DWORD nCurrentFrameNumber = m_pAviPlayer->GetCurrentFrameNumber();
if( nCurrentFrameNumber == 0){ // first frame
m_nTimerStart = GetTickCount();
m_pAviPlayer->m_nFrameSkiped = 0;
}
nCurrentTimePlayed = nTimerSpeed * m_pAviPlayer->m_nStartFrameNumber;
nCurrentTimeNeeded = GetTickCount()-m_nTimerStart;
}
while( nCurrentTimePlayed < nCurrentTimeNeeded );
m_pAviPlayer->m_nFrameSkiped += (i-1);
Invalidate();
return;
}
CWnd::OnTimer(nIDEvent);
}
//////////////////////////////////////////////////////////////////////////
int CAviPlayerWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CWnd::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
//////////////////////////////////////////////////////////////////////////
void CAviPlayerWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
if( m_pAviPlayer == NULL )
return;
m_pAviPlayer->DrawFrame(dc,m_pAviPlayer->m_nFrameNumber);
}
//////////////////////////////////////////////////////////////////////////
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.