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

📄 performerdlg.cpp

📁 wince图形界面的开发
💻 CPP
字号:
/************************************************************************************
File Name		:	PerformerDlg.cpp

Class Name		:	MECPerformerDlg

Description		:	Implementation file

Developed by	:	B.Manivannan

Date			:	24-10-2001
*************************************************************************************/
#include "stdafx.h"
#include "Performer.h"
#include "PerformerDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// MECPerformerDlg dialog

MECPerformerDlg::MECPerformerDlg(CWnd* pParent /*=NULL*/)
	: CDialog(MECPerformerDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(MECPerformerDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	MECPerformerDlg::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 MECPerformerDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(MECPerformerDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(MECPerformerDlg, CDialog)
	//{{AFX_MSG_MAP(MECPerformerDlg)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON1, OnRunOrStop)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/************************************************************************************
Function Name	:	OnInitDialog

Class Name		:	MECPerformerDlg

Description		:	It initializes the dialog by drawing the window and X, Y axes.

Argument		:	Nothing

Return			:	BOOL
*************************************************************************************/
BOOL MECPerformerDlg::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_CUSTOM)->GetWindowRect(rect) ;
	ScreenToClient(rect) ;
	GetDlgItem(IDC_GRAPH_CUSTOM)->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
}
/************************************************************************************
Function Name	:	RegisterWndClass

Class Name		:	MECPerformerDlg

Description		:	This static function is must to draw the graph in the custom control

Argument		:	HINSTANCE hInstance

Return			:	BOOL
*************************************************************************************/
BOOL MECPerformerDlg::RegisterWndClass(HINSTANCE hInstance)
{
	WNDCLASS wc;
	wc.lpszClassName = _T("GRAPH_CUSTOM"); // 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);
}
/************************************************************************************
Function Name	:	OnTimer

Class Name		:	MECPerformerDlg

Description		:	It is being called with respect to the timer. It gives the points
					sequentially.

Argument		:	UINT nIDEvent

Return			:	BOOL
*************************************************************************************/
void MECPerformerDlg::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);
}
/************************************************************************************
Function Name	:	OnRunOrStop

Class Name		:	MECPerformerDlg

Description		:	The user has to click to start the graph or to stop the graph.

Argument		:	UINT nIDEvent

Return			:	BOOL
*************************************************************************************/
void MECPerformerDlg::OnRunOrStop() 
{
	// TODO: Add your control notification handler code here
	m_bStartStop ^= TRUE;

	  if (m_bStartStop)
		SetTimer(1,1000,NULL);
	  else
		KillTimer(1);
}

⌨️ 快捷键说明

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