⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bkstatic.cpp

📁 一个完整的数字硬盘录像机系统软件
💻 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((nx<rect.right)||(ny<rect.bottom))
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pBKObject->Draw(pDC,rTmpRect);
		  if(nx<rect.right)
		     nx+=m_pBKObject->GetWidth();
		  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(nx<rect.right)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject->Draw(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(nx<rect.right)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject->Draw(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(ny<rect.bottom)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject90->Draw(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(ny<rect.bottom)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject90->Draw(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((nx<rect.right)||(ny<rect.bottom))
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pBKObject->Draw(pDC,rTmpRect);
		  if(nx<rect.right)
		     nx+=m_pBKObject->GetWidth();
		  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(nx<rect.right)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject->Draw(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(nx<rect.right)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject->Draw(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(ny<rect.bottom)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject90->Draw(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(ny<rect.bottom)
		{
          rTmpRect.IntersectRect(rDrawRect,rect);
		  m_pFrameObject90->Draw(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;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -