Multi Line Chart Control | CodeGuru

Multi Line Chart Control

  Download Source Code Download Example Project This control class CLineChartCtrl is derived from CWnd. The original idea and part of the code are from Ken C. Len’s CHistogramCtrl. I did some changes to make the control work in multi lines. I was trying to make a CPU usage app that would work both under […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 16, 1998
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

 

Download Source Code

Download Example Project

This control class CLineChartCtrl is derived from CWnd. The original idea and part of
the code are from Ken C. Len’s CHistogramCtrl. I did
some changes to make the control work in multi lines. I was trying to make a CPU usage app
that would work both under Windows95/98 and NT, but I failed. I know now how to get CPU
usage under Windows 95/98 through the registry (See the article Q174631 from Microsoft).
But the code does not work under NT:-).

I found something very interesting in Ndis.vxd(Win95/98) and Ndis.Dll(NT) – there is a
function called NdisGetCurrentProcessorCpuUsage(). Will this function solve all
the problems? I don’t know. I can load the library and receive the address for the
function, but I don’t have the parameters. If anyone knows anything about it, I will
appreciate if you let me know!

The sample project is created and compiled with Visual C++ 5.0 SP3 under Windows 98.

How to use

1. Use the MS Visual C++ dialog editor to place a custom control on the dialog, and
enter "LINE_CHART_CTRL" as the Class name.

2. Add a CPieChartCtrl class member in the header file

#include "LineChartCtrl.h"
...
CLineChartCtrl m_wndLineChart;

3. Subclass the class member with the control in InitDialog()

//IDC_LINE_CHART_CTRL is the control ID
m_wndLineChart.SubclassDlgItem(IDC_LINE_CHART_CTRL, this);

4. Initiate the control

m_wndLineChart.Add(RGB(0,255,0),100, 0);
m_wndLineChart.Add(RGB(255,255,0),100, 0);
m_wndLineChart.Add(RGB(0,255,255),100, 0);

SetTimer(1, 500, NULL); // Create a timer to update the control

5. Add update code in OnTimer(UINT nIDEvent)

m_wndLineChart.SetPos(0,nPos0); // nPos0 is the currect postion
m_wndLineChart.SetPos(1,nPos1); // nPos1 is the currect postion
m_wndLineChart.SetPos(2,nPos2); // nPos2 is the currect postion
m_wndLineChart.Go(); // Make sure that the control updates with the new value

Last updated: 13 August 1998

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.