?? drawcurvedlg.cpp
字號(hào):
// drawcurveDlg.cpp : implementation file
//
#include "stdafx.h"
#include "drawcurve.h"
#include "drawcurveDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDrawcurveDlg dialog
CDrawcurveDlg::CDrawcurveDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDrawcurveDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDrawcurveDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
CDrawcurveDlg::RegisterWndClass(AfxGetInstanceHandle());
m_bStartStop = FALSE;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_dXValue[0] = 0.5;m_dXValue[1] = 1;m_dXValue[2] = 2;m_dXValue[3] = 3.5;
m_dXValue[4] = 5;m_dXValue[5] = 6;m_dXValue[6] = 7;m_dXValue[7] = 8;
m_dYValue[0] = 2;m_dYValue[1] = 3;m_dYValue[2] = 4;m_dYValue[3] = 5.5;
m_dYValue[4] = 7;m_dYValue[5] = 8;m_dYValue[6] = 8.5;m_dYValue[7] = 9;
m_nTimerIndex = 0;
}
void CDrawcurveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDrawcurveDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDrawcurveDlg, CDialog)
//{{AFX_MSG_MAP(CDrawcurveDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnRunOrStop)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDrawcurveDlg message handlers
BOOL CDrawcurveDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
CRect rect;
GetDlgItem(IDC_GRAPH_CUSTOM1)->GetWindowRect(rect) ;
ScreenToClient(rect) ;
GetDlgItem(IDC_GRAPH_CUSTOM1)->ShowWindow(SW_HIDE);
// create the control
m_oGraphCtrl.Create(WS_VISIBLE | WS_CHILD, rect, this) ;
m_oGraphCtrl.SetXRange(0,10,2);
m_oGraphCtrl.SetRange(0, 10, 2) ;
m_oGraphCtrl.SetYUnits("Volume in ml") ;
m_oGraphCtrl.SetXUnits("Time in seconds") ;
m_oGraphCtrl.SetBackgroundColor(RGB(0, 0, 64)) ;
m_oGraphCtrl.SetGridColor(RGB(192, 192, 255)) ;
m_oGraphCtrl.SetPlotColor(RGB(0, 255, 0)) ;
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CDrawcurveDlg::RegisterWndClass(HINSTANCE hInstance)
{
WNDCLASS wc;
wc.lpszClassName = _T("GRAPH_CUSTOM1"); // matches class name in client
wc.hInstance = hInstance;
wc.lpfnWndProc = ::DefWindowProc;
//wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = 0;
wc.lpszMenuName = NULL;
wc.hbrBackground = (HBRUSH) ::GetStockObject(LTGRAY_BRUSH);
wc.style = CS_GLOBALCLASS; // To be modified
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
return (::RegisterClass(&wc) != 0);
}
void CDrawcurveDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
double nRandomY, nRandomX;
// generate a random number between 0 and 10
//nRandomY = 10.0*rand()/(double)RAND_MAX;
//nRandomX = 10.0*rand()/(double)RAND_MAX;
if(m_nTimerIndex == 8) KillTimer(1);
nRandomX = m_dXValue[m_nTimerIndex];
nRandomY = m_dYValue[m_nTimerIndex];
m_nTimerIndex++;
// append the new value to the plot
m_oGraphCtrl.AppendPoint(nRandomX, nRandomY);
CDialog::OnTimer(nIDEvent);
}
void CDrawcurveDlg::OnRunOrStop()
{
// TODO: Add your control notification handler code here
m_bStartStop ^= TRUE;
if (m_bStartStop)
SetTimer(1,100,NULL);
else
KillTimer(1);
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -