CStatic-derived histogram control | CodeGuru

CStatic-derived histogram control

Environment: VC5-6, Win9x, NT4-2000 Actually I wrote this code on VC6.0 and check them with BoundChecker 6.0. The CAlexfStaticHistogram control is a lightweight class suitable for displaying histograms. You can add new columns, additional text, change text orientation and direction of motion (if you change data at runtime). Using CAlexfStaticHistogram in a dialog is quite […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 21, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Sample Image

Environment: VC5-6, Win9x, NT4-2000
Actually I wrote this code on VC6.0 and check them with BoundChecker 6.0.

The CAlexfStaticHistogram control is a lightweight class suitable for
displaying histograms. You can add new columns, additional text,
change text orientation and direction of motion (if you change data at
runtime).

Using CAlexfStaticHistogram in a dialog is quite simple:
1. Include CAlexfStaticHistogram.h in your dialog class’ header file.
2.Add member variables of type CAlexfStaticHistogram for every
static text control you want to subclass.
3.Subclass the static text controls in your dialog’s OnInitDialog()
method and set the controls’ style.

m_sHistogram.SetTextWidth(50); // Set text width (0 - no text)
m_sHistogram.SetTextLines(5);  // Set number of text lines (0 - none)
m_sHistogram.text[0] = "Z1";   // Set text (too easy to create special
m_sHistogram.text[1] = "Zz2";  // function for that)
// ...
m_sHistogram.SetMaxValue(99.9) // Set relatival maximum
m_sHistogram.Add(50);          // Add new column to histogram

If you want “dynamic” histogram – you can owerride, for example,
OnTimer() and simply call:

m_sHistogram.Add(/*Value*/);

Please feel free to send me any suggestions about this control.

Downloads

Download demo project – 20 Kb

Download source – 2 Kb

History

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.