?? draw2dgraphdlg.cpp
字號:
// Draw2DGraphDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Draw2DGraph.h"
#include "Draw2DGraphDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDraw2DGraphDlg dialog
CDraw2DGraphDlg::CDraw2DGraphDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDraw2DGraphDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDraw2DGraphDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDraw2DGraphDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDraw2DGraphDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDraw2DGraphDlg, CDialog)
//{{AFX_MSG_MAP(CDraw2DGraphDlg)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDraw2DGraphDlg message handlers
BOOL CDraw2DGraphDlg::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;
rect.left = 10;
rect.top = 10;
rect.right = 240;
rect.bottom = 160;
//創建曲線控件實例
m_2DGraph.m_crBackColor = RGB(118,146,131); //控件背景色
m_2DGraph.m_crGridColor = RGB(56,104,169); //邊框顏色
m_2DGraph.m_crLineColor = RGB(136,253,57); //曲線顏色
m_2DGraph.m_crTextColor = RGB(122,122,122); //字體顏色
m_2DGraph.Create(_T(""),_T(""),WS_VISIBLE | WS_CHILD, rect, this,0,NULL) ;
m_pointCount = 0;
//啟動添加點計時器
SetTimer(1,100,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CDraw2DGraphDlg::OnTimer(UINT nIDEvent)
{
int nRandomY, nRandomX;
//產生一個1到10的隨機數
nRandomX = rand() % 10;
nRandomY = rand() % 10;
//如果曲線點數大于10個點,則刪除第1個點。
if (m_pointCount > 10 )
{
m_2DGraph.DeleteFirstPoint();
m_pointCount--;
}
//給曲線添加點
m_2DGraph.AppendPoint(nRandomX, nRandomY);
m_pointCount++;
CDialog::OnTimer(nIDEvent);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -