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

📄 dlgpulsemeter.cpp

📁 一个开源的心电图测量仪驱动和应用软件,可记录
💻 CPP
字号:
// DlgPulseMeter.cpp : implementation file
//

#include "stdafx.h"
#include "ECG_1.h"
#include "DlgPulseMeter.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgPulseMeter dialog


CDlgPulseMeter::CDlgPulseMeter(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgPulseMeter::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgPulseMeter)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDlgPulseMeter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgPulseMeter)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgPulseMeter, CDialog)
	//{{AFX_MSG_MAP(CDlgPulseMeter)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgPulseMeter message handlers

void CDlgPulseMeter::DrawPulse()
{
	CClientDC dc(this);
	CRect rect;
	GetWindowRect(rect);

	CBitmap Bitmap;
	CBitmap* pbmOld = NULL;//Pointer to the CBitmap object
	CDC dcMem;
	CRect BmpRect;
	BmpRect.SetRect(0,0,rect.right,rect.bottom);
	dcMem.CreateCompatibleDC(&dc);//Greate painting object
	Bitmap.CreateCompatibleBitmap(&dc,BmpRect.Width(),BmpRect.Height());
	//In to DCMem is getting the object bitmap
	pbmOld = dcMem.SelectObject(&Bitmap);
	//Creates the bitmap rectangle
	dcMem.PatBlt(0,0,rect.right,rect.bottom,WHITENESS);
	//Draw curr pulse
	DrawCurrPulse(&dcMem,&BmpRect);
	//Draw past pulse in last minute
	DrawPastPulse(&dcMem,&BmpRect);

	//Shows the bitmap on the dlg screen dY=100
	dc.BitBlt(0,0,rect.right,
		rect.bottom,&dcMem,0,0,SRCCOPY);

	dcMem.SelectObject(pbmOld);
	dcMem.DeleteDC();
}

void CDlgPulseMeter::DrawCurrPulse(CDC *pDC,CRect *lpRect)
{
	CFont Font;
	CRect rect;
	GetClientRect(rect);

//	s_CurrPulse = "4";

	int text_lenght = s_CurrPulse.GetLength();
	int fHeight = rect.Height();
	int fWidth = rect.Width()/(4*text_lenght);
	
	
	int x = ((3*rect.Width()/4) - (fWidth*text_lenght)/2);

	
	Font.CreateFont(fHeight,fWidth,0,0,
		FW_DONTCARE,FALSE,FALSE,0,
		DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,
		CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE,
		"Arial");

	CFont* pOldFont = pDC->SelectObject(&Font);
	pDC->TextOut(x,10,s_CurrPulse);		
	pDC->MoveTo(rect.Width()/2,rect.top);
	pDC->LineTo(rect.Width()/2,rect.bottom);
	pDC->SelectObject(pOldFont);
}

void CDlgPulseMeter::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	DrawPulse();
	
	// Do not call CDialog::OnPaint() for painting messages
}

void CDlgPulseMeter::DrawPastPulse(CDC *pDC, CRect lprect)
{
	CFont Font;
	CRect rect;
	GetClientRect(rect);

//	s_PastPulse = "708";
	int text_lenght = s_PastPulse.GetLength();
	int fHeight = rect.Height();
	int fWidth = rect.Width()/(4*text_lenght);
	
	int x = ((rect.Width()/4) - (fWidth*text_lenght)/2);

	Font.CreateFont(fHeight,fWidth,0,0,
		FW_DONTCARE,FALSE,FALSE,1,
		DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,
		CLIP_CHARACTER_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE,
		"Arial");

	CFont* pOldFont = pDC->SelectObject(&Font);
	pDC->TextOut(x,10,s_PastPulse);			
	pDC->SelectObject(pOldFont);

}

⌨️ 快捷键说明

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