Scroll Chart Control

Click here for larger image

Environment: Win2K SP2, VC6 SP4

Simply, this is a chart with support for "history". For bugs and improvements mail me, Thz.

The class has the following features:

  • Any number of lines.
  • Different styles, colors and width for each line.
  • Unlimited number of points per line, or you can put limit if you want.
  • Configurable grid.
  • Hscroll.
  • Automatic adjustment to vertical values.
  • ...

How to use

1. Declare a CScrollChart object -- it's a template you must use to specify a type of data.

CScrollChart< float > m_wndChart;

2. Use Create (See help file for values).

m_wndChart.Create( WS_VISIBLE | GS_NOTIFY, 

3. Add lines.

m_wndChart.AddLine(ID_LINE1, RGB(255,0,0));
m_wndChart.AddLine(ID_LINE2, RGB(0,0,255), LS_POINT | LS_HORZAUTO);
You can add new lines at any moment.

4. Add data to line.

m_wndChart.AddData(ID_LINE1, 3, 9);
m_wndChart.AddData(ID_LINE1, 10, 2);
m_wndChart.AddData(ID_LINE2, 3);
m_wndChart.AddData(ID_LINE2, 5);
m_wndChart.AddData(ID_LINE2, 34);


Download demo project - 14 Kb
Download source - 2 Kb
Download help - 7 Kb


  • Healing Erectile Dysfunction In Diabetics: Can Gene Treatments Balance The blue pill Efficacy?

    Posted by anieffifielm on 06/21/2013 03:18am

    The strategy to Select Best Erectile Dysfunction Treatment? Having trouble maintaining an erection before or during sexual intercourse [url= ] viagra y cialis generico [/url] read far more Erectile Dysfunction Cure

  • Problem with compilation

    Posted by Legacy on 02/26/2004 12:00am

    Originally posted by: Petr Hracek

    Hey all,

    It's very great work. It's excelent.
    I have one big problem. I tried compile this demo code
    and MSVC++.NET2003 sow me message that _GetBaseMessageMap is not a member of CScrollChart <T>.

    And other error:
    d:\Temp\test\cldemo.cpp(47): error C2440: 'static_cast' : cannot convert from 'void (__thiscall CDialogMain::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'

    Can you help me anybody?


  • I found the one

    Posted by Legacy on 02/24/2004 12:00am

    Originally posted by: mingligar

    Thanks. your projet is The one I want to find. I get it.

  • can it display infinite data?

    Posted by Legacy on 10/31/2003 12:00am

    Originally posted by: edward

    can this display data as much as I like, or huge quantities?

  • Here is the solution of drawing negative value.

    Posted by Legacy on 08/06/2003 12:00am

    Originally posted by: Taghi

    << In the class file >>
    Change the "LPtoDP(T X,T Y)" function as the folowing :

    template<class T>
    CPoint CScrollChart<T>::LPtoDP(T X,T Y)
    int nY;
    int nX;
    CRect rectClient;
    nY = ((rectClient.Height() * (Y-m_MinValue) * 0.95) /( m_MaxValue-m_MinValue));
    nX = ((rectClient.Width() * (X - m_pointIni)) / m_nHzRange);
    return CPoint(nX, rectClient.Height() - nY);

    << In your program >>
    And if you want to refresh the min vertical limit textbox
    as in the demo program only in "OnNewLimits" message
    mapped function uncomment the folloing statment:

    //else m_TextVerMax.SetWindowText(strTmp);

    So that the whole function can looked as follow:

    void CTest02Dlg::OnNewLimits(WPARAM wParam, LPARAM lParam)
    CString strTmp;
    if ( (GetCurrentMessage()->message) == WM_NEWHORZLIMITS) m_TextHozMin.SetWindowText(strTmp);
    else m_TextVerMin.SetWindowText(strTmp);
    if ( (GetCurrentMessage()->message) == WM_NEWHORZLIMITS) m_TextHozMax.SetWindowText(strTmp);
    else m_TextVerMax.SetWindowText(strTmp);

  • Problem with the .Create

    Posted by Legacy on 04/28/2003 12:00am

    Originally posted by: Maarten


    BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);

    Specifies the chart control's ID.

    What is the chart control's ID? Is is the scrollbar?
    This header looks wonderfull but I can't get it running...
    In the example it has value 101. Why? I can't find the reason...

    Thanks for help!!


  • Concern about memory size

    Posted by Legacy on 08/13/2002 12:00am

    Originally posted by: Amit

    for your help.That u have suggested is one away solution and i also find other solution
    Create pointer
    CScrollChart *myscrollchart;
    myscrollchart=new CScrollChart();
    this work fine

    Now I have concern about memory size.
    when I put four scrollchart controls having 3 to 4 lines each with 0 timer the memory uses increases drastically.And CPU usage is also 99% which affect other application's working.
    So can any one suggest how to clip the control.
    Window display as of size of control would be sufficient for me.


  • To Delete control(sonia's solution not working)

    Posted by Legacy on 08/02/2002 12:00am

    Originally posted by: Amit

    I want to delete the control on the fly. but code suggested by sonia seems to be not working in my case.
    It is giving error while creating pointer of the template class CScrollChart .If any one knows the solution please help me


  • Problem Adding Lines..

    Posted by Legacy on 06/25/2002 12:00am

    Originally posted by: Jeremy

    Hello, thanks for the control. It looks very useful. I am able to draw the chart, but when I do AddLine and AddData nothing happens - I can't draw any lines on the chart.
    Can you give me any info that may help with this issue?


  • Print

    Posted by Legacy on 06/19/2002 12:00am

    Originally posted by: Helena

    How can I print the graph?

  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Lenovo recommends Windows 8 Pro. "I dropped my laptop getting out of the taxi." This probably sounds familiar to most IT professionals. If your employees are traveling, you know their devices are in for a rough go. Whether it's a trip to the conference room or a convention out of town, any time equipment leaves a user's desk it is at risk of being put into harm's way. Stay connected at all times, whether at the office or on the go, with agile, durable, and flexible devices like the Lenovo® …

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date