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

📄 resultdlg2.cpp

📁 开发的锌流量计算程序
💻 CPP
字号:
// ResultDlg2.cpp : implementation file
//

#include "stdafx.h"
#include "ShaoYe.h"
#include "ResultDlg2.h"
#include "shaoyedoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CResultDlg2 dialog


CResultDlg2::CResultDlg2(CWnd* pParent /*=NULL*/)
	: CDialog(CResultDlg2::IDD, pParent)
{
	//{{AFX_DATA_INIT(CResultDlg2)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	show_flag=true;
}


void CResultDlg2::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CResultDlg2)
	DDX_Control(pDX, IDC_STATIC1, m_flux_pic);
	DDX_Control(pDX, IDC_BUTTON3, m_ThirdBtn);
	DDX_Control(pDX, IDC_BUTTON2, m_SecondBtn);
	DDX_Control(pDX, IDC_BUTTON1, m_FirstBtn);
	DDX_Control(pDX, IDC_LABEL1, m_label);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CResultDlg2, CDialog)
	//{{AFX_MSG_MAP(CResultDlg2)
	ON_WM_PAINT()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CResultDlg2 message handlers

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

	if(show_flag)
	{
		Drawing(0);
		Drawing(0);
		show_flag=false;
	}

	// TODO: Add your message handler code here
	
	// Do not call CDialog::OnPaint() for painting messages
}

void CResultDlg2::OnButton1() 
{
	// TODO: Add your control notification handler code here
	m_FirstBtn.EnableWindow(FALSE);
	m_SecondBtn.EnableWindow(TRUE);
	m_ThirdBtn.EnableWindow(TRUE);
	m_SecondBtn.SetFocus();
	Drawing(0);
	Drawing(0);
}

void CResultDlg2::OnButton2() 
{
	// TODO: Add your control notification handler code here
	m_FirstBtn.EnableWindow(TRUE);
	m_SecondBtn.EnableWindow(FALSE);
	m_ThirdBtn.EnableWindow(TRUE);
	m_ThirdBtn.SetFocus();
	Drawing(1);
	Drawing(1);
}

void CResultDlg2::OnButton3() 
{
	// TODO: Add your control notification handler code here

	m_FirstBtn.EnableWindow(TRUE);
	m_SecondBtn.EnableWindow(TRUE);
	m_ThirdBtn.EnableWindow(FALSE);
	m_FirstBtn.SetFocus();
	Drawing(2);
	Drawing(2);
}

void CResultDlg2::Drawing(int period)
{
	if(!show_flag)
	{
		InvalidateRect( NULL, TRUE );
		UpdateWindow(); 
	}
	
	CShaoYeDoc* pDoc = (CShaoYeDoc*)(((CFrameWnd *)(AfxGetApp()->m_pMainWnd))->GetActiveDocument());
	CDC *pdc=m_flux_pic.GetWindowDC();
	pdc->SetBkMode(TRANSPARENT);

	CString strdate;
	strdate.Format("%4d年%02d月%02d日",yyear,mmonth,dday);
	if(period==0)
		m_label.SetCaption(strdate+"早班流量曲线图");
	else if(period==1)
		m_label.SetCaption(strdate+"中班流量曲线图");
	else if(period==2)
		m_label.SetCaption(strdate+"晚班流量曲线图");


	CPen CyanPen(PS_SOLID, 1, RGB(128,128,128));
	CPen BluePen(PS_SOLID, 2, RGB(0,0,255));
	CPen VioletPen(PS_SOLID,1,RGB( 255, 0, 255 ));

	pdc->SelectObject (BluePen);
	//x轴及箭头
	pdc->MoveTo(35,430);
	pdc->LineTo(875,430);
	pdc->LineTo(865,428);
	pdc->LineTo(865,432);
	pdc->LineTo(875,430);
   //y轴及箭头
	pdc->MoveTo(35,430);
    pdc->LineTo(35,5);
	pdc->LineTo(33,15);
	pdc->LineTo(37,15);
	pdc->LineTo(35,5);


	pdc->SelectObject(CyanPen);
	int i;//y轴刻度
	for(i=0;i<10;i++)
	{
		pdc->MoveTo(28,430-42*i);
		pdc->LineTo(855,430-42*i);
		CString str;
		str.Format("%2d",15+i);
		pdc->TextOut(15,430-42*i-8,str);
	}
	int j;//x轴刻度
	for(j=0;j<=8;j++)
	{
		pdc->MoveTo((int)(35+810.0/8*j),20);
		pdc->LineTo((int)(35+810.0/8*j),432);
		CString str;
		str.Format("%2d",period*8+j);
		pdc->TextOut((int)(35+810.0/8*j-8),435,str);
	}
	pdc->TextOut(860,435,"小时");
	pdc->TextOut(5,5,"流量");

	pdc->SelectObject(VioletPen);

	BOOL zero_flag=false;
	pdc->MoveTo(35,(int)(430-(pDoc->query_flux1[period][0]-15)*42));
	for(j=1;j<5760;j=j+1)
	{
		if((pDoc->query_flux1[period][j]==0)&&(!zero_flag))
		{
			pDoc->query_flux1[period][j]=pDoc->query_flux1[period][j-1];
			zero_flag=true;
		}
		else
			zero_flag=false;
		if(!zero_flag)
			pdc->LineTo((int)(35+j*810.0/5760),(int)(430-(pDoc->query_flux1[period][j]-15)*42));
		else
			pdc->MoveTo((int)(35+j*810.0/5760),(int)(430-(pDoc->query_flux1[period][j]-15)*42));
	}

/*	for(j=0;j<5760;j++)
	{
		pdc->SetPixel((int)(35+j*810.0/5760),(int)(430-(pDoc->query_flux[period][j]-15)*42),RGB(255,0,0));
	}*/

	ReleaseDC(pdc);

}

⌨️ 快捷键说明

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