www.pudn.com > SpliterView.rar > MyVideoWnd.cpp
// MyVideoWnd.cpp : implementation file
//
#include "stdafx.h"
#include "SpliterView.h"
#include "MyVideoWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyVideoWnd
CMyVideoWnd::CMyVideoWnd()
{
}
CMyVideoWnd::~CMyVideoWnd()
{
}
BEGIN_MESSAGE_MAP(CMyVideoWnd, CStatic)
//{{AFX_MSG_MAP(CMyVideoWnd)
ON_WM_PAINT()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyVideoWnd message handlers
void CMyVideoWnd::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect clientRect;
GetClientRect(&clientRect);
CBitmap tempbitmap;
if(m_bitmap_No)
tempbitmap.LoadBitmap(IDB_BITMAP1);
else
tempbitmap.LoadBitmap(IDB_BITMAP2);
BITMAP bmpInfo;
tempbitmap.GetBitmap(&bmpInfo);
CDC tempDc;
tempDc.CreateCompatibleDC(&dc);
CBitmap* pOldBitmap = tempDc.SelectObject(&tempbitmap);
dc.StretchBlt (0, 0, clientRect.Width(),clientRect.Height(), &tempDc,0,0, bmpInfo.bmWidth, bmpInfo.bmHeight, SRCCOPY);
tempDc.SelectObject(pOldBitmap);
// Do not call CStatic::OnPaint() for painting messages
}
void CMyVideoWnd::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
m_bitmap_No=(m_bitmap_No+1)%2;
Invalidate(TRUE);
CStatic::OnTimer(nIDEvent);
}
void CMyVideoWnd::MySetTimer()
{
srand( (unsigned)time( NULL ) );
int nInterval = (rand()%5+1)*100;
m_nTimer = SetTimer(1,nInterval,0);
}
void CMyVideoWnd::MyKillTimer()
{
KillTimer(m_nTimer);
}