资源描述
一个原创地仪表控件
路过世纪飞扬的网站发现好些个仪表控件,可惜都要付费,这对于很多用户来说不得不说是一件憾事。最近两天导师项目不忙,就抽空做了一个仪表控件,是对照别人的仪表外观做的,在此公布出来大家讨论讨论,最好大家都写些免费的控件放在网上,好资源共享。如果有兄弟觉得好用的话,请在使用处留下俺的名号,这就够给我面子了。
1.效果图
2.CMeter类的使用方法
(1) Meter.cpp和Meter.h以及MemDC.h加入到你的工程中。
(2) 在你的工程中放入一个图片框控件,并通过类向导声明一个CStatic类的对象,例如叫m_myMeter。
(3) 用CMeter替换m_myMeter的CStatic。
(4) 利用CMeter类的接口函数初始化。
(5) 更新数值UpdateNeedle(double dValue),显示指针变化。
3.接口函数介绍
SetNeedleColor(COLORREF colorNeedle) 设置指针颜色
SetRange(double dMin, double dMax) 设置仪表最大值最小值
SetScaleDecimals(int nDecimals) 设置刻度显示精度(小数点后位数)
SetValueDecimals(int nDecimals) 设置数值显示精度(小数点后位数)
SetUnits(CString &strUnits) 设置单位
SetColorTick(BOOL bColorTick) 是否显示彩色刻度
SetTicks(int nTicks) 设置主刻度(分几大格)
SetSubTicks(int nSubTicks) 设置子刻度(每大格分为几小格)
SetAngleRange(int nStartAngleDeg, int nEndAngleDeg) 表盘圆弧起始终止角度
========================================================================
MICROSOFT FOUNDATION CLASS LIBRARY : MyMeter
========================================================================
AppWizard has created this MyMeter application for you. This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.
This file contains a summary of what you will find in each of the files that
make up your MyMeter application.
MyMeter.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
MyMeter.h
This is the main header file for the application. It includes other
project specific headers (including Resource.h) and declares the
CMyMeterApp application class.
MyMeter.cpp
This is the main application source file that contains the application
class CMyMeterApp.
MyMeter.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
MyMeter.clw
This file contains information used by ClassWizard to edit existing
classes or add new classes. ClassWizard also uses this file to store
information needed to create and edit message maps and dialog data
maps and to create prototype member functions.
res\MyMeter.ico
This is an icon file, which is used as the application's icon. This
icon is included by the main resource file MyMeter.rc.
res\MyMeter.rc2
This file contains resources that are not edited by Microsoft
Visual C++. You should place all resources not editable by
the resource editor in this file.
/////////////////////////////////////////////////////////////////////////////
AppWizard creates one dialog class:
MyMeterDlg.h, MyMeterDlg.cpp - the dialog
These files contain your CMyMeterDlg class. This class defines
the behavior of your application's main dialog. The dialog's
template is in MyMeter.rc, which can be edited in Microsoft
Visual C++.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named MyMeter.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
If your application uses MFC in a shared DLL, and your application is
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC42XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation.
For example, MFC42DEU.DLL contains resources translated to German.) If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.
/////////////////////////////////////////////////////////////////////////////
展开阅读全文