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

📄 generalpicdlg.cpp

📁 数据结构链表的演示程序
💻 CPP
字号:
// GeneralPicDlg.cpp : implementation file
//

#include "stdafx.h"
#include "LandSoft.h"
#include "GeneralPicDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CGeneralPicDlg dialog


CGeneralPicDlg::CGeneralPicDlg(CWnd* pParent,
		BYTE xnum,BYTE ynum,
		double * xcoords,double * ycoords,
		double ymin,double ymax,
		CString xname,CArray<CString,CString> * ynames,
		COLORREF * ycolors,BYTE * ylegends)
	: CDialog(CGeneralPicDlg::IDD, pParent)
{
	m_nXNum=xnum;
	m_nYNum=ynum;
	m_aXCoords=xcoords;
	m_aYCoords=ycoords;
	m_dXMin=xcoords[0];
	m_dXMax=xcoords[xnum-1];
	m_dYMin=ymin;
	m_dYMax=ymax;
	m_dXDist=m_dXMax-m_dXMin;
	m_dYDist=m_dYMax-m_dYMin;
	m_strXName=xname;
	m_astrYNames=ynames;
	m_aclrYColors=ycolors;
	m_aYLegends=ylegends;
}


void CGeneralPicDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGeneralPicDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGeneralPicDlg, CDialog)
	//{{AFX_MSG_MAP(CGeneralPicDlg)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGeneralPicDlg message handlers

void CGeneralPicDlg::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	CPen *pen;
	CBrush * cbBack=new CBrush(RGB(255,255,255));
	CRect rect(42,42,442,342);
	dc.FillRect(rect,cbBack);

	UINT x0=42;
	UINT y0=342;

	dc.SetBkMode(TRANSPARENT);

	double xzoom=400/m_dXDist;
	double yzoom=300/m_dYDist;

	double nowx,nowy;

	for(int yindex=0;yindex<m_nYNum;yindex++)
	{
		pen=new CPen(PS_SOLID,1,m_aclrYColors[yindex]);
		dc.SelectObject(pen);

		CString legend;
		nowx=x0;
		nowy=y0-(m_aYCoords[yindex]-m_dYMin)*yzoom;
		legend.Format("%c",LegendChar[m_aYLegends[yindex]]);
		
		dc.SetTextColor(m_aclrYColors[yindex]);
		dc.TextOut(nowx-4,nowy-8,legend);
		dc.MoveTo(nowx,nowy);

		for(int xindex=1;xindex<m_nXNum;xindex++)
		{
			nowx=x0+(m_aXCoords[xindex]-m_dXMin)*xzoom;
			nowy=y0-(m_aYCoords[yindex+xindex*m_nYNum]-m_dYMin)*yzoom;

			dc.TextOut(nowx-4,nowy-8,legend);
			dc.LineTo(nowx,nowy);
		}

		delete pen;
	}

	delete cbBack;
}

⌨️ 快捷键说明

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