資源簡介
本科畢業設計 用VC++實現工業組態軟件一些常用的控件如指示燈、按鈕、溫度計、壓力計等

代碼片段和文件信息
//?3DMeterCtrl.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“math.h“?
#include?“3DMeterCtrl.h“
#include?“MemDC.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?C3DMeterCtrl
C3DMeterCtrl::C3DMeterCtrl()
{
m_dCurrentValue??=??0.0?;
m_dMaxValue??????=??5.0?;
m_dMinValue??????=?-5.0?;
m_nScaleDecimals?=?1?;
m_nValueDecimals?=?3?;
m_strUnits.Format(“Volts“)?;
m_colorNeedle?=?RGB(255?0?0)?;
}
C3DMeterCtrl::~C3DMeterCtrl()
{
if?((m_pBitmapOldBackground)?&&?
??(m_bitmapBackground.GetSafeHandle())?&&?
(m_dcBackground.GetSafeHdc()))
m_dcBackground.Selectobject(m_pBitmapOldBackground);
}
BEGIN_MESSAGE_MAP(C3DMeterCtrl?CStatic)
//{{AFX_MSG_MAP(C3DMeterCtrl)
ON_WM_PAINT()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?C3DMeterCtrl?message?handlers
void?C3DMeterCtrl::OnPaint()?
{
CPaintDC?dc(this);?//?device?context?for?painting
//?Find?out?how?big?we?are
GetClientRect?(&m_rectCtrl)?;
//?make?a?memory?dc
CMemDC?memDC(&dc?&m_rectCtrl);
//?set?up?a?memory?dc?for?the?background?stuff?
//?if?one?isn‘t?being?used
if?((m_dcBackground.GetSafeHdc()?==?NULL)?||?(m_bitmapBackground.m_hobject?==?NULL))
{
m_dcBackground.CreateCompatibleDC(&dc)?;
m_bitmapBackground.CreateCompatibleBitmap(&dc?m_rectCtrl.Width()?
m_rectCtrl.Height())?;
m_pBitmapOldBackground?=?m_dcBackground.Selectobject(&m_bitmapBackground)?;
//?Fill?this?bitmap?with?the?background.
//?Note:?This?requires?some?serious?drawing?and?calculating?
//?therefore?it?is?drawn?“once“?to?a?bitmap?and?
//?the?bitmap?is?stored?and?blt‘d?when?needed.
DrawMeterBackground(&m_dcBackground?m_rectCtrl)?;
}
//?drop?in?the?background
memDC.BitBlt(0?0?m_rectCtrl.Width()?m_rectCtrl.Height()?
???????????&m_dcBackground?0?0?SRCCOPY)?;
//?add?the?needle?to?the?background
DrawNeedle(&memDC)?;
//?add?the?value?to?the?background
DrawValue(&memDC)?;
}
void?C3DMeterCtrl::DrawValue(CDC?*pDC)
{
CFont?*pFontOld?;
CString?strTemp?;
//?Pick?up?the?font.
//?Note:?the?font?was?determined?in?the?drawing
//?of?the?background
??pFontOld?=?pDC->Selectobject(&m_fontValue)?;
//?set?the?colors?based?on?the?system?colors
pDC->SetTextColor(m_colorText)?;
pDC->SetBkColor(m_colorButton)?;
//?draw?the?text?in?the?recessed?rectangle
pDC->SetTextAlign(TA_CENTER|TA_baseLINE)?;
strTemp.Format(“%.*f“?m_nValueDecimals?m_dCurrentValue)?;
pDC->TextOut(m_nValueCenter?m_nValuebaseline?strTemp)?;
//?restore?the?color?and?the?font
pDC->SetBkColor(m_colorWindow)?;
??pDC->Selectobject(pFontOld)?;
}
void?C3DMeterCtrl::UpdateNeedle(double?dValue)
{
m_dCurrentValue?=?dValue?;
Invalidate()?;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????15555??2010-05-28?09:38??ZhangPengCheng\3DMeterCtrl.cpp
?????文件???????2452??2010-05-28?09:38??ZhangPengCheng\3DMeterCtrl.h
?????文件???????7991??2010-05-28?14:27??ZhangPengCheng\Compass.cpp
?????文件???????1834??2010-05-28?14:27??ZhangPengCheng\Compass.h
?????文件??????46704??2010-06-20?10:34??ZhangPengCheng\Debug\3DMeterCtrl.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\3DMeterCtrl.sbr
?????文件??????24913??2010-06-20?10:34??ZhangPengCheng\Debug\Compass.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\Compass.sbr
?????文件??????22492??2010-06-20?10:34??ZhangPengCheng\Debug\DynamicLED.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\DynamicLED.sbr
?????文件??????57390??2010-06-20?10:34??ZhangPengCheng\Debug\Meter.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\Meter.sbr
?????文件???????4782??2010-06-20?10:34??ZhangPengCheng\Debug\PIDControl.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\PIDControl.sbr
?????文件??????78061??2010-06-20?10:34??ZhangPengCheng\Debug\RoundSliderCtrl.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\RoundSliderCtrl.sbr
?????文件??????43265??2010-06-20?10:35??ZhangPengCheng\Debug\ScaleUnit.obj
?????文件??????????0??2010-06-20?10:35??ZhangPengCheng\Debug\ScaleUnit.sbr
?????文件??????37050??2010-06-20?10:34??ZhangPengCheng\Debug\StaticTime.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\StaticTime.sbr
?????文件?????106080??2010-06-20?10:34??ZhangPengCheng\Debug\StdAfx.obj
?????文件????1374958??2010-06-20?10:34??ZhangPengCheng\Debug\StdAfx.sbr
?????文件??????16654??2010-06-20?10:34??ZhangPengCheng\Debug\SwitchStatic.obj
?????文件??????????0??2010-06-20?10:34??ZhangPengCheng\Debug\SwitchStatic.sbr
?????文件?????238592??2010-06-20?10:40??ZhangPengCheng\Debug\vc60.idb
?????文件?????380928??2010-06-20?10:39??ZhangPengCheng\Debug\vc60.pdb
?????文件????5481472??2010-06-20?10:39??ZhangPengCheng\Debug\ZhangPengCheng.bsc
?????文件?????315493??2010-06-20?10:39??ZhangPengCheng\Debug\ZhangPengCheng.exe
?????文件?????513652??2010-06-20?10:39??ZhangPengCheng\Debug\ZhangPengCheng.ilk
?????文件??????19453??2010-06-20?10:35??ZhangPengCheng\Debug\ZhangPengCheng.obj
............此處省略58個文件信息
評論
共有 條評論