Click here to Skip to main content
Click here to Skip to main content

COscilloscopeCtrl

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

Introduction

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;
GetDlgItem(IDC_STATIC_OSCILLOSCOPE)->GetWindowRect(rect);
ScreenToClient(rect);
m_Oscilloscope.Create(WS_VISIBLE | WS_CHILD, rect, this, 
    IDC_OSCILLOSCOPE);

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.

Todo

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! Smile | :)

License

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

Share

About the Author

Tanzim Husain
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralOnSize PinsussAnonymous7-Oct-03 16:14 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 15 Mar 2003
Article Copyright 2003 by Tanzim Husain
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid