資源簡介
一個漂亮的VC++示波器生成類附源碼實例,美觀實用,如果你在編寫一款采樣軟件,那么這個示例或許對你很有用,另附上一個示例代碼,希望對大家有所幫助。該類提供了一些方法可供調用,比較方便。如果要顯示采集到的數據,只要簡單的調用AddValue和UpdateCurve就可以了。

代碼片段和文件信息
//?Scope1.cpp?:?implementation?file
//?Download?by?http://www.codefans.net
#include?“stdafx.h“
#include?“resource.h“
#include?“Scope.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CScope
CScope::CScope()
{
m_strtitle?=?_T(“示波器“);
m_strValueName?=?_T(“數值“);
m_strUnitName?=?_T(“度“);
m_BkBrush.CreateSolidBrush(RGB(0x000x000x33));
m_PanelBrush.CreateSolidBrush(RGB(0x220x220x44));
m_CurveBrush.CreateSolidBrush(RGB(0x000x000x00));
m_PenCurve.CreatePen(PS_SOLID2RGB(02550));
m_PenGrid.CreatePen(PS_SOLID0RGB(192192192));
m_PenBrightLine.CreatePen(PS_SOLID0RGB(0xff0xff0xff));
m_PenDarkLine.CreatePen(PS_SOLID0RGB(0x550x550x55));
m_Fonttitle.CreateFont(18000FW_BOLDFALSEFALSEFALSEDEFAULT_CHARSET
OUT_DEFAULT_PRECISCLIP_DEFAULT_PRECISDEFAULT_QUALITYDEFAULT_PITCH“宋體“);
m_FontAxis.CreateFont(15000FW_THINFALSEFALSEFALSEDEFAULT_CHARSET
OUT_DEFAULT_PRECISCLIP_DEFAULT_PRECISDEFAULT_QUALITYDEFAULT_PITCH“Arial“);
m_FontValue.CreatePointFont(120“FixedSys“);
m_FontLabel.CreatePointFont(120“Times?New?Roman“);
m_bitmaptitle.LoadBitmap(IDB_title);
m_bitmapTrack.LoadBitmap(IDB_TRACK);
m_dDimT =?1.0;
m_dDimY =?2.5;
m_nbase?=?5;
m_nRange?=?10;
m_dValue=?0.0;
m_nArrowIndex?=-1;
m_bPressed?=?FALSE;
}
CScope::~CScope()
{
if(!m_TimeList.empty())
m_TimeList.clear();
if(!m_ValueList.empty())
m_ValueList.clear();
}
BEGIN_MESSAGE_MAP(CScope?CStatic)
//{{AFX_MSG_MAP(CScope)
ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_LBUTTONUP()
ON_WM_LBUTTONDOWN()
ON_WM_MOUSEMOVE()
ON_WM_NCHITTEST()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CScope?message?handlers
BOOL?CScope::OnEraseBkgnd(CDC*?pDC)?
{
//?TODO:?Add?your?message?handler?code?here?and/or?call?default
CRect?rect;
GetClientRect(&rect);
pDC->FillRect(&rect&m_BkBrush);//Draw?background
rect.InflateRect(-3-25-4-60);//curve?panel
m_rectCurvePanel?=?rect;
m_rectCurve?=?rect;
m_rectCurve.InflateRect(-30-5-23-25);//curve?area
m_rectScroll?=?m_rectCurve;
m_rectScroll.left?=?m_rectCurve.right+8;
m_rectScroll.right?=?m_rectScroll.left+10;//rect?scroll?created
m_rectValuePanel?=?rect;
m_rectValuePanel.top?=?rect.bottom+5;
m_rectValuePanel.bottom=?m_rectValuePanel.top+51;//rectValuePanel?created
CFont?*pOldFont;
pOldFont?=?pDC->Selectobject(&m_FontLabel);
CSize?size?=?pDC->GetTextExtent(m_strValueName);
m_rectValue.left?=?m_rectValuePanel.left+20+size.cx;
m_rectValue.top?=?m_rectValuePanel.top+(m_rectValuePanel.Height()-size.cy)/2-2;
m_rectValue.bottom?=?m_rectValue.top+size.cy+4;
size?=?pDC->GetTextExtent(m_strUnitName);
m_rectValue.right?=?m_rectValuePanel.right?-?20?-?size.cx;
pDC->Selectobject(pOldFont);
if(m_rgnCu
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3627??2004-09-08?16:42??Scope\ReadMe.txt
?????文件???????3978??2004-09-08?16:44??Scope\res\ti
?????文件????????726??2004-09-08?16:44??Scope\res\Track.bmp
?????文件???????1078??2004-09-08?16:42??Scope\res\示波器演示.ico
?????文件????????402??2004-09-08?16:42??Scope\res\示波器演示.rc2
?????文件????????870??2004-09-08?16:51??Scope\resource.h
?????文件??????19513??2009-11-30?16:00??Scope\Scope.cpp
?????文件???????3019??2004-08-27?14:24??Scope\Scope.h
?????文件????????212??2004-09-08?16:42??Scope\StdAfx.cpp
?????文件???????1054??2004-09-08?16:42??Scope\StdAfx.h
?????文件??????25940??2009-11-30?15:52??Scope\示波器演示.aps
?????文件???????1244??2009-11-30?15:52??Scope\示波器演示.clw
?????文件???????2067??2009-11-30?16:00??Scope\示波器演示.cpp
?????文件???????4496??2004-09-08?17:00??Scope\示波器演示.dsp
?????文件????????545??2004-09-08?16:42??Scope\示波器演示.dsw
?????文件???????1298??2004-09-08?16:42??Scope\示波器演示.h
?????文件???????5593??2004-09-08?16:51??Scope\示波器演示.rc
?????文件???????5127??2009-11-30?16:00??Scope\示波器演示Dlg.cpp
?????文件???????1367??2004-09-08?16:55??Scope\示波器演示Dlg.h
?????文件??????19477??2004-09-08?16:46??Scope\類代碼\Scope.cpp
?????文件???????3019??2004-08-27?14:24??Scope\類代碼\Scope.h
?????目錄??????????0??2012-08-18?07:43??Scope\res
?????目錄??????????0??2012-08-18?07:43??Scope\類代碼
?????目錄??????????0??2012-08-18?07:43??Scope
-----------?---------??----------?-----??----
???????????????104652????????????????????24
- 上一篇:C/C++課程設計-學生成績管理系統
- 下一篇:馬的極小滿覆蓋源代碼C++編寫
評論
共有 條評論