www.pudn.com > 数字硬盘录像机软件代码.rar > Bkstatic.cpp


// BKButton.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "GtMpeg.h" 
#include "BKStatic.h" 
#include "ImageObject.h" 
#ifdef _DEBUG  
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
///////////////////////////////////////////////////////////////////////////// 
// 
///////////////////////////////////////////////////////////////////////////// 
CBKStatic::CBKStatic() 
{ 
   m_pFrameObject=NULL; 
   m_pFrameObject90=NULL; 
   m_pBKObject=NULL; 
} 
///////////////////////////////////////////////////////////////////////////// 
// 
///////////////////////////////////////////////////////////////////////////// 
CBKStatic::~CBKStatic() 
{ 
   if(m_pFrameObject!=NULL) 
	   delete m_pFrameObject; 
   if(m_pFrameObject90!=NULL) 
	   delete m_pFrameObject; 
   if(m_pBKObject!=NULL) 
	   delete m_pBKObject; 
} 
///////////////////////////////////////////////////////////////////////////// 
// 
///////////////////////////////////////////////////////////////////////////// 
BEGIN_MESSAGE_MAP(CBKStatic, CStatic) 
	//{{AFX_MSG_MAP(CBKStatic) 
	ON_WM_ERASEBKGND() 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
///////////////////////////////////////////////////////////////////////////// 
// 
///////////////////////////////////////////////////////////////////////////// 
///////////////////////////////////////////////////////////////////////////// 
// 
///////////////////////////////////////////////////////////////////////////// 
void CBKStatic::SetObject(CString sFrameName,CString sBKName) 
{ 
   if(m_pFrameObject!=NULL) 
   { 
	   delete m_pFrameObject; 
       m_pFrameObject=NULL; 
   } 
   if(m_pFrameObject90!=NULL) 
   { 
	   delete m_pFrameObject; 
	   m_pFrameObject=NULL; 
   } 
   if(m_pBKObject!=NULL) 
   { 
	   delete m_pBKObject; 
	   m_pBKObject=NULL; 
   } 
   CFileFind Find; 
   if(Find.FindFile(sFrameName)!=0) 
   { 
      m_pFrameObject=new CImageObject(sFrameName); 
	  m_pFrameObject90=new CImageObject(sFrameName); 
      m_pFrameObject90->Rotate(90);  
   } 
   if(Find.FindFile(sBKName)!=0) 
   { 
      m_pBKObject=new CImageObject(sBKName); 
   } 
   RedrawWindow(); 
} 
//////////////////////////////////////////////////// 
// 
/////////////////////////////////////////////////// 
void CBKStatic::DrawItem(LPDRAWITEMSTRUCT lpDIS) 
{ 
  CDC  *pDC = CDC::FromHandle(lpDIS->hDC); 
  if(m_pBKObject!=NULL) 
  { 
	   	CRect rect,rDrawRect,rTmpRect; 
		GetClientRect(rect); 
		rect.left=20; 
		rect.top=20; 
		rect.right-=20; 
		rect.bottom-=20; 
		int nx=rect.left,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pBKObject->GetWidth(); 
		rDrawRect.bottom=ny+m_pBKObject->GetHeight(); 
		while((nxDraw(pDC,rTmpRect); 
		  if(nxGetWidth(); 
		  else  
		  { 
			 nx=0; 
			 ny+=m_pBKObject->GetHeight(); 
		  } 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pBKObject->GetWidth(); 
		  rDrawRect.bottom=ny+m_pBKObject->GetHeight(); 
		} 
	} 
	if(m_pFrameObject!=NULL) 
	{ 
	   	CRect rect,rDrawRect,rTmpRect; 
		GetClientRect(rect); 
		if(m_pFrameObject->GetHeight()<20) 
		  rect.bottom=rect.top+m_pFrameObject->GetHeight(); 
		else 
          rect.bottom=rect.top+20; 
		int nx=0,ny=0; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		while(nxDraw(pDC,rTmpRect); 
		  nx+=m_pBKObject->GetWidth(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		} 
		// 
		GetClientRect(rect); 
		if(m_pFrameObject->GetHeight()<20) 
		  rect.top=rect.bottom-m_pFrameObject->GetHeight(); 
		else 
          rect.top=rect.bottom-20; 
		nx=0,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		while(nxDraw(pDC,rTmpRect); 
		  nx+=m_pFrameObject->GetWidth(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		} 
		// 
		GetClientRect(rect); 
		if(m_pFrameObject90->GetWidth()<20) 
		  rect.left=rect.right-m_pFrameObject90->GetWidth(); 
		else 
          rect.left=rect.right-20; 
		nx=rect.left,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		while(nyDraw(pDC,rTmpRect); 
		  ny+=m_pFrameObject90->GetHeight(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		} 
		// 
		GetClientRect(rect); 
		if(m_pFrameObject90->GetWidth()<20) 
		  rect.right=rect.left+m_pFrameObject90->GetWidth(); 
		else 
          rect.right=rect.left+20; 
		nx=rect.left,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		while(nyDraw(pDC,rTmpRect); 
		  ny+=m_pFrameObject90->GetHeight(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		} 
	} 
} 
//////////////////////////////////////////// 
// 
////////////////////////////////////////// 
BOOL CBKStatic::OnEraseBkgnd(CDC* pDC)  
{ 
  if(m_pBKObject!=NULL) 
  { 
	   	CRect rect,rDrawRect,rTmpRect; 
		GetClientRect(rect); 
		rect.left=20; 
		rect.top=20; 
		rect.right-=20; 
		rect.bottom-=20; 
		int nx=rect.left,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pBKObject->GetWidth(); 
		rDrawRect.bottom=ny+m_pBKObject->GetHeight(); 
		while((nxDraw(pDC,rTmpRect); 
		  if(nxGetWidth(); 
		  else  
		  { 
			 nx=0; 
			 ny+=m_pBKObject->GetHeight(); 
		  } 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pBKObject->GetWidth(); 
		  rDrawRect.bottom=ny+m_pBKObject->GetHeight(); 
		} 
	} 
	if(m_pFrameObject!=NULL) 
	{ 
	   	CRect rect,rDrawRect,rTmpRect; 
		GetClientRect(rect); 
		if(m_pFrameObject->GetHeight()<20) 
		  rect.bottom=rect.top+m_pFrameObject->GetHeight(); 
		else 
          rect.bottom=rect.top+20; 
		int nx=0,ny=0; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		while(nxDraw(pDC,rTmpRect); 
		  nx+=m_pFrameObject->GetWidth(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		} 
		// 
		GetClientRect(rect); 
		if(m_pFrameObject->GetHeight()<20) 
		  rect.top=rect.bottom-m_pFrameObject->GetHeight(); 
		else 
          rect.top=rect.bottom-20; 
		nx=0,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		while(nxDraw(pDC,rTmpRect); 
		  nx+=m_pFrameObject->GetWidth(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject->GetHeight(); 
		} 
		// 
		GetClientRect(rect); 
		if(m_pFrameObject90->GetWidth()<20) 
		  rect.left=rect.right-m_pFrameObject90->GetWidth(); 
		else 
          rect.left=rect.right-20; 
		nx=rect.left,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		while(nyDraw(pDC,rTmpRect); 
		  ny+=m_pFrameObject90->GetHeight(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		} 
		// 
		GetClientRect(rect); 
		if(m_pFrameObject90->GetWidth()<20) 
		  rect.right=rect.left+m_pFrameObject90->GetWidth(); 
		else 
          rect.right=rect.left+20; 
		nx=rect.left,ny=rect.top; 
		rDrawRect.left=nx; 
		rDrawRect.top=ny; 
		rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		while(nyDraw(pDC,rTmpRect); 
		  ny+=m_pFrameObject90->GetHeight(); 
		  rDrawRect.left=nx; 
		  rDrawRect.top=ny; 
		  rDrawRect.right=nx+m_pFrameObject90->GetWidth(); 
		  rDrawRect.bottom=ny+m_pFrameObject90->GetHeight(); 
		} 
	} 
	if(m_pFrameObject==NULL&&m_pBKObject==NULL) 
	   return CStatic::OnEraseBkgnd(pDC); 
  return TRUE; 
}