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

📄 testrecordgraphdlg.cpp

📁 一款不错的关于绘制波形编程的软件源代码
💻 CPP
字号:
// testRecordGraphDlg.cpp : implementation file
//

#include "stdafx.h"
#include "testRecordGraph.h"
#include "testRecordGraphDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestRecordGraphDlg dialog

CTestRecordGraphDlg::CTestRecordGraphDlg(CWnd* pParent /*=NULL*/)
	: CResizableDialog(CTestRecordGraphDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTestRecordGraphDlg)
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTestRecordGraphDlg::DoDataExchange(CDataExchange* pDX)
{
	CResizableDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTestRecordGraphDlg)
//	DDX_Control(pDX, IDC_BUTTON_OPENFILE, m_btnOpenFile);
//	DDX_Control(pDX, IDC_BUTTON_CANCEL, m_btnCancel);
	DDX_Control(pDX, IDC_CUSTOM1, m_graph);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTestRecordGraphDlg, CResizableDialog)
	//{{AFX_MSG_MAP(CTestRecordGraphDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_TESTDRAW, OnTestdraw)
	ON_BN_CLICKED(IDC_TESTFILE, OnTestfile)
	ON_BN_CLICKED(IDC_BUTTON_PRE, OnButtonPre)
	ON_BN_CLICKED(IDC_BUTTON_NEXT, OnButtonNext)
	ON_BN_CLICKED(IDC_RADIOBASELINEONE, OnRadiobaselineone)
	ON_BN_CLICKED(IDC_RADIOBASELINETWO, OnRadiobaselinetwo)
	ON_BN_CLICKED(IDC_BTN_TEST, OnBtnTest)
	ON_BN_CLICKED(IDC_OPENFILE, OnOpenfile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestRecordGraphDlg message handlers

BOOL CTestRecordGraphDlg::OnInitDialog()
{
	CResizableDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// 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
	
	// TODO: Add extra initialization here
//	AddAnchor(IDC_BUTTON_CANCEL, BOTTOM_RIGHT);
//	AddAnchor(IDC_BUTTON_OPENFILE, BOTTOM_RIGHT);
	
	AddAnchor(IDC_CUSTOM1, TOP_LEFT, BOTTOM_RIGHT);

//	m_graph.SetMargin(10, 10, 10, 20);	
//	m_graph.SetGridSize(20, 20);

	GetDlgItem(IDC_BUTTON_PRE)->EnableWindow(FALSE);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CTestRecordGraphDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CResizableDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.
void CTestRecordGraphDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CResizableDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CTestRecordGraphDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CTestRecordGraphDlg::OnTestdraw() 
{
	// TODO: Add your control notification handler code here
//	m_graph.SetMargin(20, 10, 10, 20);	
//	m_graph.SetGridSize(15, 15);
	
	LPCTSTR filePath = "F:\\record1\\2008.11.18.1.20.2-2008.11.26.1.23.37.bin";
	m_graph.m_FilePath = filePath;
	m_graph.m_nCurDrawNum = 0;
	m_graph.Invalidate();
	//Invalidate();			

}

void CTestRecordGraphDlg::OnTestfile() 
{
	// TODO: Add your control notification handler code here
	TRY
	{	COleDateTime t1(2008, 11, 17, 17, 20, 03);
		COleDateTime t2(2008, 11, 17, 17, 23, 37);

		CRecordFile file("F:\\weichai.bin",t1,t2);
		int count = file.GetDataPageCount();
		
		CDataPage page;
		CDataPage Outpage;
		//BYTE TempBcdTime[6];
		//page.bcdTime = TempBcdTime;
		file.GetHeadDataPage(&page);
		file.GetTailDataPage(&page);
		
		COleDateTime t(2008, 11, 17, 17, 20, 03);
		file.GetDataPageAt(t, &page);
		file.GetDataPageAt(5, &page);
		
		file.GetNextDataPage(&page, &Outpage);
		file.GetPrevDataPage(&page, &Outpage);
		file.GetDataPageRelativeTo(&page, 7, &Outpage);
		
		file.GetDataPageAt(3, &page);
		file.GetDataPageMiddleOf(0, 9, &page);
		
		
		COleDateTime time;
		
		file.GetHeadDataPageTime(time);	
		file.GetTailDataPageTime(time);
		
		
	}
	CATCH(CFileException, e)
	{ 
	}
	CATCH(CRecordException, e)
	{
		//TRACE("ErrorDescription:%s\n",e->GetErrorDecription());
	}
	END_CATCH
}

void CTestRecordGraphDlg::OnButtonPre() 
{
	// TODO: Add your control notification handler code here
	if(m_graph.m_FilePath==NULL)
		return;
	m_graph.m_nCurDrawNum --;
	if(m_graph.m_nCurDrawNum < 0)
	{
		m_graph.m_nCurDrawNum ++;
		GetDlgItem(IDC_BUTTON_PRE)->EnableWindow(FALSE);
	}
	else
	{
		GetDlgItem(IDC_BUTTON_NEXT)->EnableWindow(TRUE);
		m_graph.Invalidate();		
	}
}

void CTestRecordGraphDlg::OnButtonNext() 
{
	// TODO: Add your control notification handler code here
	if(m_graph.m_FilePath==NULL)
		return;
	m_graph.m_nCurDrawNum ++;
	if(m_graph.m_nCurDrawNum>=m_graph.m_nDrawPageNum)
	{
		m_graph.m_nCurDrawNum --;
		GetDlgItem(IDC_BUTTON_NEXT)->EnableWindow(FALSE);
	}
	else
	{
		GetDlgItem(IDC_BUTTON_PRE)->EnableWindow(TRUE);
		m_graph.Invalidate();	
	}	
}

void CTestRecordGraphDlg::OnRadiobaselineone() 
{
	// TODO: Add your control notification handler code here
	m_graph.nCheck = 1;
}

void CTestRecordGraphDlg::OnRadiobaselinetwo() 
{
	// TODO: Add your control notification handler code here
	m_graph.nCheck = 2;
}

void CTestRecordGraphDlg::OnBtnTest() 
{
	// TODO: Add your control notification handler code here
	int nAverage = 0;
	m_graph.OnAverage(nAverage);
	CString str;
	str.Format("%d",nAverage);
	AfxMessageBox(str);
}

void CTestRecordGraphDlg::OnOpenfile() 
{
	// TODO: Add your control notification handler code here
	m_graph.SendMessage(WM_GRAPHMESSAGE,0,0);
}

⌨️ 快捷键说明

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