Click here to Skip to main content
13,090,541 members (55,543 online)
Click here to Skip to main content
Add your own
alternative version


37 bookmarked
Posted 14 Mar 2003


, 14 Mar 2003
Rate this:
Please Sign up or sign in to vote.
An oscilloscope control with multiple band(frequency) support


Recently, one of the projects that I'm working on required showing some variable data, like signal strength, signal to noise ratio etc. As usual, I dived into Code Project, confident that I'll find a solution. I did find some, as expected, but unfortunately, none of them fit my requirements. First of all, I needed to show variables of different type, i.e. the control needed to have multiple bands. Secondly, the code needed to be windows CE compliant.

After some review, I choose Mehdi Mousavi's CHistogramCtrl, which was good enough to be portable to windows CE. All I did was add some modifications to include multiple bands support and that's it.

Using the code

Using  the code is pretty simple. All you do is add bands to the control using new instances of the COscilloscopeBand object. For example in the dialog's OnInitDialog method.

// m_Oscilloscope is the instance of COscilloscopeCtrl
m_Oscilloscope.m_Bands.Add(new COscilloscopeBand(_T("Band1"), 
    RGB(0x99, 0xFF, 0x66), 1, 1, 100));
m_Oscilloscope.m_Bands.Add(new COscilloscopeBand(_T("Band2"), 
    RGB(0, 0, 255), 1, 1, 200));

// Create the scope ctrl itself..., we'll place it over an 
//already existing static ctrl in the dialog
CRect rect;
m_Oscilloscope.Create(WS_VISIBLE | WS_CHILD, rect, this, 

You can set the position of a band by calling its SetPos method. You must also call DrawBands each time you want to update the display. COscilloscopeCtrl also contains some other helpful methods to modify the individual bands Pen width, color etc. Check out the source code.


Draw some sort of a legend to describe a band. I included a band name for a band's constructor for that purpose, but never got around doing it. Some help! :)


This article, along with any associated source code and files, is licensed under The BSD License


About the Author

Tanzim Husain
Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralOnSize Pin
Anonymous7-Oct-03 16:14
sussAnonymous7-Oct-03 16:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 15 Mar 2003
Article Copyright 2003 by Tanzim Husain
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid