CStatic-derived histogram control

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



Comments

  • Histogram

    Posted by Legacy on 07/27/2002 12:00am

    Originally posted by: Amit

    The contor is good.But want some addition property such as to chane color of hostogram and inspite of showing it's bar and wnat to display line connection top points so how should I proceed. And want to add more than one suct display in single window

    Reply
  • cool control

    Posted by Legacy on 11/04/2001 12:00am

    Originally posted by: Adrian Ciomaga

    Hi,

    It is a really cool control. I modified it a little bit to allow the user to select the bkcolor and the drawing color. There are minor changes, though. If you need them, I can email the new files to you.

    Best regards,

    Adrian.

    Reply
  • History Gram

    Posted by Legacy on 06/22/1999 12:00am

    Originally posted by: Roger L. Mcelfresh

    Hi! I hate pushing buttons, so I added this to your program. m_flag is defined in your header file and is intitially set "true" then the first time you press "add value" it starts the 1 second timer.

    void CAlexfHistogramDlg::OnButton1()
    {
    if (m_flag)
    {
    if (!SetTimer(1, 1000 /* Start timer*/, NULL)) // 1 second
    {
    MessageBox(_T("Not enough timers available for this window!"),
    _T("DLG:Histogram"), MB_ICONEXCLAMATION | MB_OK);
    }
    m_flag = false;
    }
    else
    {
    KillTimer(1);
    m_flag = true;
    }

    }

    void CAlexfHistogramDlg::OnTimer(UINT nIDEvent)
    {
    // TODO: Add your message handler code here and/or call default
    m_sHistogram.Add((DOUBLE) rand() / (DOUBLE) RAND_MAX * 100);

    CDialog::OnTimer(nIDEvent);
    }


    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • It's no secret what keeps CIOs up at night. Mobile, cloud, data, security, and social have become the "five imperatives," the drivers of business progress, innovation, and competitive differentiation. Business leaders around the world want to hear how other companies are succeeding. How are they applying the latest technologies? How did they get started? What outcomes are they achieving? Read this online magazine for success stories from organizations like the NBA, Pfizer, and San Jose State University as they …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds