Click here to Skip to main content
15,881,600 members
Articles / Desktop Programming / MFC
Article

Digital Meter Control

Rate me:
Please Sign up or sign in to vote.
4.87/5 (17 votes)
12 Jul 20071 min read 114.3K   5.6K   99   30
A digital meter control of virtual instruments

Screenshot - digitalcontrol.png

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:

  1. Copy the files DigitalControl.h and DigitalControl.cpp to your project directory and add them to your project.
  2. Place a Static Control to your dialog from the Control ToolBox.
  3. 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.
  4. In your dialog class header file, add this line on top of your class definition:
    C++
    DigitalControl.h
  5. Replace the following line in your dialog class header file...
    C++
    CStatic m_meter;
    ...with this line:
    C++
    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:

C++
void setType(int t); 
//Set the type of the meter. 0=Horiz. 1=Vert. 
. 
void reDraw(); 
//Redraw the meter 
. 
void setLimit(double min,double max); 
//Set the range of the meter 
. 
void setValue(double v); 
//Set the dispaly value of the meter. 
. 
double getValue(); 
//Get the display value of the meter 
. 
void setBackgroundColor(int c1,int c2,int c3); 
//Set the background of the meter. 
//c1=Fill color. c2=First Border color. c3=Second Border color. 
. 
void setGradientColor(int c1,int c2); 
//Set the gradient bar color. c1=First gradient color.. 
//c2=Second gradient color.. 
. 
void setScaleColor(int c1,int c2); 
//Set the scale color. c1=Trangle color.. c2=Scale line color.. 
. 
void setTextColor(int c1); 
//Set the text color. c1=Text color.

History

  • 14 March, 2007 -- Original version posted
  • 12 July, 2007 -- Article edited and posted to the main CodeProject.com article base

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Researcher
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralTranslated to C# Pin
varnk20-Oct-08 3:34
varnk20-Oct-08 3:34 
GeneralRe: Translated to C# Pin
Luca_v7411-Oct-11 4:00
Luca_v7411-Oct-11 4:00 
GeneralRe: Translated to C# Pin
varnk11-Oct-11 4:23
varnk11-Oct-11 4:23 
GeneralRe: Translated to C# Pin
Jason.LYJ19-Sep-15 16:25
professionalJason.LYJ19-Sep-15 16:25 
GeneralNice Control Pin
Paul Conrad14-Jul-07 8:18
professionalPaul Conrad14-Jul-07 8:18 
Generalnegative values Pin
del Fuego23-Mar-07 8:29
del Fuego23-Mar-07 8:29 
GeneralNice looking control..thanks! Pin
CodeHead19-Mar-07 3:18
CodeHead19-Mar-07 3:18 
Generalpublic data members Pin
toxcct15-Mar-07 23:18
toxcct15-Mar-07 23:18 
GeneralRe: public data members Pin
Lingsong16-Mar-07 2:40
Lingsong16-Mar-07 2:40 
GeneralRe: public data members Pin
toxcct16-Mar-07 2:42
toxcct16-Mar-07 2:42 
GeneralGood One Pin
dharam14-Mar-07 20:18
dharam14-Mar-07 20:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.