Introduction
This article explains how to add a digital meter control to your dialog-based application. This digital meter control is derived from CStatic. You can customize the digital meter as you require.
Using the code
Steps for adding the digital meter control to your application:
- Copy the files DigitalControl.h and DigitalControl.cpp to your project directory and add them to your project.
- Place a Static Control to your dialog from the Control ToolBox.
- Using ClassWizard, add a member variable -- such as m_meter for the Static Control -- to your dialog class. Make sure that it is a control variable.
- In your dialog class header file, add this line on top of your class definition:
DigitalControl.h
- Replace the following line in your dialog class header file...
CStatic m_meter;
...with this line:
CDigitalControl m_meter;
That's all. The digital meter control is now in your application. Just execute the program to view it.
Member functions
Following are the member functions that can be used to change the digital meter control settings:
void setType(int t);
.
void reDraw();
.
void setLimit(double min,double max);
.
void setValue(double v);
.
double getValue();
.
void setBackgroundColor(int c1,int c2,int c3);
.
void setGradientColor(int c1,int c2);
.
void setScaleColor(int c1,int c2);
.
void setTextColor(int c1);
History
- 14 March, 2007 -- Original version posted
- 12 July, 2007 -- Article edited and posted to the main CodeProject.com article base
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.