📄 resultdlg1.cpp
字号:
// ResultDlg1.cpp : implementation file
//
#include "stdafx.h"
#include "ShaoYe.h"
#include "ResultDlg1.h"
#include "Querydlg1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CResultDlg1 dialog
CResultDlg1::CResultDlg1(CWnd* pParent /*=NULL*/)
: CDialog(CResultDlg1::IDD, pParent)
{
//{{AFX_DATA_INIT(CResultDlg1)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
period=0;
show_flag=true;
}
void CResultDlg1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CResultDlg1)
DDX_Control(pDX, IDC_COMBO1, m_timeCmb);
DDX_Control(pDX, IDC_BUTTON3, m_nextbtn);
DDX_Control(pDX, IDC_BUTTON1, m_prevbtn);
DDX_Control(pDX, IDC_STATIC1, m_flux_pic);
DDX_Control(pDX, IDC_LABEL1, m_label);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CResultDlg1, CDialog)
//{{AFX_MSG_MAP(CResultDlg1)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CResultDlg1 message handlers
BOOL CResultDlg1::OnInitDialog()
{
CDialog::OnInitDialog();
CString str;
str.Format("%4d年%02d月%02d日",yyear,mmonth,dday);
m_label.SetCaption(str);
m_timeCmb.SetCurSel(0);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CResultDlg1::OnButton1()
{
// TODO: Add your control notification handler code here
m_nextbtn.EnableWindow(TRUE);
period--;
m_timeCmb.SetCurSel(period);
Drawing(period);
if(period<1)
{
period=1;
m_prevbtn.EnableWindow(FALSE);
m_nextbtn.SetFocus();
}
}
void CResultDlg1::Drawing(int time)
{
if(!show_flag)
{
InvalidateRect( NULL, TRUE );
UpdateWindow();
}
CShaoYeDoc* pDoc = (CShaoYeDoc*)(((CFrameWnd *)(AfxGetApp()->m_pMainWnd))->GetActiveDocument());
CDC *pdc=m_flux_pic.GetWindowDC();
pdc->SetBkMode(TRANSPARENT);
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<13;j++)
{
pdc->MoveTo((int)(35+810.0/12*j),20);
pdc->LineTo((int)(35+810.0/12*j),432);
CString str;
str.Format("%2d",5*j);
pdc->TextOut((int)(35+810.0/12*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_flux[time][0]-15)*42));
for(j=1;j<720;j++)
{
if((pDoc->query_flux[time][j]==0)&&(!zero_flag))
{
pDoc->query_flux[time][j]=pDoc->query_flux[time][j-1];
zero_flag=true;
}
else
zero_flag=false;
if(!zero_flag)
pdc->LineTo((int)(35+j*810.0/720),(int)(430-(pDoc->query_flux[time][j]-15)*42));
else
pdc->MoveTo((int)(35+j*810.0/720),(int)(430-(pDoc->query_flux[time][j]-15)*42));
}
ReleaseDC(pdc);
}
void CResultDlg1::OnButton3()
{
// TODO: Add your control notification handler code here
m_prevbtn.EnableWindow(TRUE);
period++;
m_timeCmb.SetCurSel(period);
Drawing(period);
if(period>22)
{
period=22;
m_nextbtn.EnableWindow(FALSE);
m_prevbtn.SetFocus();
}
}
void CResultDlg1::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
if(show_flag)
{
Drawing(0);
show_flag=false;
}
// Do not call CDialog::OnPaint() for painting messages
}
BOOL CResultDlg1::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::Create(IDD, pParentWnd);
}
HBRUSH CResultDlg1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
pDC->SetBkColor(RGB(255,255,255));
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CResultDlg1::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
period=m_timeCmb.GetCurSel();
Drawing(period);
if(period==0)
{
m_prevbtn.EnableWindow(FALSE);
m_nextbtn.EnableWindow(TRUE);
}
else if(period==23)
{
m_prevbtn.EnableWindow(TRUE);
m_nextbtn.EnableWindow(FALSE);
}
else
{
m_prevbtn.EnableWindow(TRUE);
m_nextbtn.EnableWindow(TRUE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -