Click here to Skip to main content
Licence 
First Posted 14 Mar 2007
Views 71,188
Downloads 1,937
Bookmarked 77 times

Digital Meter Control

By | 12 Jul 2007 | Article
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:
    DigitalControl.h
  5. 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); 
//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

About the Author

Lingsong

Researcher

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralTranslated to C# Pinmembervarnk3:34 20 Oct '08  
GeneralRe: Translated to C# PinmemberLuca_v744:00 11 Oct '11  
GeneralRe: Translated to C# Pinmembervarnk4:23 11 Oct '11  
GeneralNice Control PinmemberPaul Conrad8:18 14 Jul '07  
Generalnegative values Pinmemberdel Fuego8:29 23 Mar '07  
GeneralNice looking control..thanks! PinmemberCodeHead3:18 19 Mar '07  
Generalpublic data members Pinmvptoxcct23:18 15 Mar '07  
GeneralRe: public data members PinmemberLingsong2:40 16 Mar '07  
GeneralRe: public data members Pinmvptoxcct2:42 16 Mar '07  
GeneralGood One Pinmemberdharam20:18 14 Mar '07  
Generalcontrol does not handle negative values Pinmemberdel Fuego16:40 21 Jul '07  
Generaldebug binary Pinmvptoxcct3:00 15 Mar '07  
QuestionRe: debug binary PinmemberMrGoodly1:45 20 Feb '08  
GeneralRe: debug binary PinmemberLingsong17:54 15 Mar '07  
GeneralRe: debug binary Pinmvptoxcct23:16 15 Mar '07  
GeneralRe: debug binary PinmemberSteve_pqr3:50 22 Mar '07  
GeneralRe: debug binary Pinmvptoxcct3:53 22 Mar '07  
GeneralRe: debug binary PinmemberSteve_pqr4:16 22 Mar '07  
GeneralRe: debug binary Pinmvptoxcct4:18 22 Mar '07  
GeneralRe: debug binary PinmemberSteve_pqr4:23 22 Mar '07  
GeneralRe: debug binary Pinmvptoxcct4:26 22 Mar '07  
GeneralRe: debug binary PinmemberSteve_pqr4:37 22 Mar '07  
GeneralRe: debug binary Pinmvptoxcct4:49 22 Mar '07  
GeneralRe: debug binary PinmemberSteve_pqr4:58 22 Mar '07  
GeneralRe: debug binary Pinmvptoxcct5:01 22 Mar '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 12 Jul 2007
Article Copyright 2007 by Lingsong
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid