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

📄 baseview.cpp

📁 本程序源码是为日本一家地震监测机构编写的
💻 CPP
字号:
// BaseView.cpp : implementation file
//

#include "stdafx.h"
#include "BaseView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBaseView

IMPLEMENT_DYNCREATE(CBaseView, CView)

CBaseView::CBaseView()
{
	m_pCmdView		=	NULL;

	m_pBitmap		=	NULL;			//位图指针初始化
	m_pMemDC		=	NULL;			//内存DC指针初始化
}

CBaseView::~CBaseView()
{
	//释放内存DC资源
	if(m_pMemDC != NULL)
	{
		m_pMemDC->DeleteDC();
		delete m_pMemDC;		
		m_pBitmap->DeleteObject();
		delete m_pBitmap;		
	}
}


BEGIN_MESSAGE_MAP(CBaseView, CView)
	//{{AFX_MSG_MAP(CBaseView)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBaseView drawing

void CBaseView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CBaseView diagnostics

#ifdef _DEBUG
void CBaseView::AssertValid() const
{
	CView::AssertValid();
}

void CBaseView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CBaseView message handlers
void CBaseView::UpdateView()
{
}

void CBaseView::ClearView()
{
}

BOOL CBaseView::IsFileExist(CString StrPN)
{
	CFileFind find;
	BOOL bfind = find.FindFile(StrPN);
	find.Close();
	return bfind;
}

BOOL CBaseView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	if(m_pCmdView != NULL)
		return m_pCmdView->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
	else
		return TRUE;
}

BOOL CBaseView::PreCreateWindow(CREATESTRUCT& cs) 
{
	cs.style &= ~WS_BORDER;
	return CView::PreCreateWindow(cs);
}

BOOL CBaseView::CreateFont(CFont &font, int nFontSize)
{
	CClientDC dc(this);
	LOGFONT lfont;
	memset(&lfont, 0, sizeof(LOGFONT));
	lfont.lfHeight = MulDiv(nFontSize, GetDeviceCaps(dc.GetSafeHdc(), LOGPIXELSX), 72); //应随分辨率调整大小
	lfont.lfWidth = 0;
	lfont.lfEscapement = 0;
	lfont.lfOrientation = 0;
	lfont.lfWeight = FW_NORMAL;
	lfont.lfItalic = FALSE;
	lfont.lfUnderline = FALSE;
	lfont.lfStrikeOut = FALSE;
	lfont.lfCharSet = DEFAULT_CHARSET; //尽量使用默认字符集
	lfont.lfOutPrecision = OUT_DEFAULT_PRECIS; 
	lfont.lfClipPrecision = CLIP_DEFAULT_PRECIS; 
	lfont.lfQuality = DEFAULT_QUALITY; //DRAFT_QUALITY是指草稿质量
	lfont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; //
	_tcscpy(lfont.lfFaceName, _T("Arial"));
	
	if(!font.CreateFontIndirect(&lfont))
	{		
		::MessageBox(AfxGetMainWnd()->GetSafeHwnd(),_T("Create Font Error!"),_T("Error"),MB_OK);
		return FALSE;
	}
	return TRUE;
}

CDC *CBaseView::CreateMemDC(CDC *pDC)
{
	ASSERT(pDC != NULL);
	//销毁上次的内存DC资源
	if(m_pMemDC != NULL)
	{
		m_pMemDC->DeleteDC();
		delete m_pMemDC;
		m_pBitmap->DeleteObject();
		delete m_pBitmap;		
	}
    //内存绘图准备///////////////////////////////
	m_pMemDC = new CDC;
	m_pBitmap = new CBitmap;
	GetClientRect(m_MemClientRect);
	m_pMemDC->CreateCompatibleDC(pDC);
	m_pBitmap->CreateCompatibleBitmap(pDC,m_MemClientRect.Width(),m_MemClientRect.Height());
	m_pMemDC->SelectObject(m_pBitmap);
	return m_pMemDC;
}

CDC *CBaseView::GetMemDC()
{
	ASSERT(m_pMemDC != NULL);
	return m_pMemDC;
}

void CBaseView::BitBltMemDC(CDC *pDC)
{
	ASSERT(m_pMemDC != NULL);
	ASSERT(pDC != NULL);
	pDC->BitBlt(0,0,m_MemClientRect.Width(),m_MemClientRect.Height(),m_pMemDC,0,0,SRCCOPY);
}





















⌨️ 快捷键说明

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