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

📄 barview.cpp

📁 一系列的c++例子 一步一步由浅入深 有 聊天室
💻 CPP
字号:
// BarView.cpp : implementation file
//

#include "stdafx.h"
#include "Ex_SplitSDI.h"
#include "Ex_SplitSDIDoc.h"
#include "BarView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBarView

IMPLEMENT_DYNCREATE(CBarView, CView)

CBarView::CBarView()
{
}

CBarView::~CBarView()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CBarView drawing

void CBarView::OnDraw(CDC* pDC)
{
	CEx_SplitSDIDoc* pDoc = GetDocument();
	// TODO: add draw code here
	CRect rc;//client area width
	int cBar,cBarSpace,x,y;
	/*cBar: bar width
	x,y: caculate position of bar drawing */
	int cxGraph=100;/*logical width ,height*/
	int cyGraph=20;

	GetClientRect(&rc);
	CBrush br1(RGB(255,0,0));
	CPen pen(PS_SOLID,1,RGB(255,0,0));
	CBrush *poldbr=pDC->SelectObject(&br1);
	CPen *poldpen=pDC->SelectObject(&pen);

	cBar=cxGraph*3/4/10;
	cBarSpace=cBar/3;
	pDC->SetMapMode(MM_ANISOTROPIC);
	pDC->SetWindowOrg(0,0);
	pDC->SetViewportOrg(10,rc.bottom-10);
	pDC->SetWindowExt(cxGraph ,cyGraph);
	pDC->SetViewportExt(rc.right-20,-rc.bottom+20);

	int i;
	for(x=cBarSpace,y=0,i=0;i<pDoc->m_nArray.GetSize();i++,x+=cBar+cBarSpace)
		pDC->Rectangle(x,y,x+cBar,y+pDoc->m_nArray[i]);
	pDC->SelectObject(poldbr);
	pDC->SelectObject(poldpen);
}

/////////////////////////////////////////////////////////////////////////////
// CBarView diagnostics

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

void CBarView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG
CEx_SplitSDIDoc* CBarView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx_SplitSDIDoc)));
	return (CEx_SplitSDIDoc*)m_pDocument;
}
/////////////////////////////////////////////////////////////////////////////
// CBarView message handlers

⌨️ 快捷键说明

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