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:
- Replace the following line in your dialog class header file...
...with this line:
That's all. The digital meter control is now in your application. Just execute the program to view it.
Following are the member functions that can be used to change the digital meter control settings:
void setType(int t);
void setLimit(double min,double max);
void setValue(double v);
void setBackgroundColor(int c1,int c2,int c3);
void setGradientColor(int c1,int c2);
void setScaleColor(int c1,int c2);
void setTextColor(int c1);
- 14 March, 2007 -- Original version posted
- 12 July, 2007 -- Article edited and posted to the main CodeProject.com article base