Introduction
Here is a simple bar graph control class derived from CStatic
. It supports displaying real-time data, using any number of bars with different colors, using scale both in cm and inch, etc.
Using the code
How to add this control to your project:
- Copy files GraphCtrl.h and GraphCtrl.cpp to your project directory, and add to your project.
- Include GraphCtrl.h in files where you need to use this class.
- Change
CStatic
definitions to CGraphCtrl
.
- Use the API described below.
int SetNumberOfBars(int num)
int SetBarColor(int idx, COLORREF clr)
void SetUnit(int unit)
void SetBarValue(int idx, int value)
Example of Use
m_Graph.SetNumberOfBars(18);
m_Graph.SetBarColor(1,RGB(200,200,200));
m_Graph.SetBarValue(1,22);
m_Graph.SetUnit(UCM);