Click here to Skip to main content
15,885,767 members
Articles / Desktop Programming / MFC
Article

GraphFX - A graph framework

Rate me:
Please Sign up or sign in to vote.
3.34/5 (30 votes)
9 Nov 2000 228K   4.5K   104   33
A Doc/View framework for displaying graphical data
  • Download demo project - 192 Kb
  • Sample Image - graphfx.gif

    Background

    The following code is based on a application I wrote to monitor Processes and Threads. I visually displayed the CPU percentages against processes/threads running on a Windows system.

    When I released the application to Code Project, many people contacted via email for either the code to do the drawing or the code to enumerate the processes. Well this is step one, the drawing code.

    Implemention

    To implement the CGraphFX frameworks, include GraphFX.h, GraphFX.cpp, Screen.h, Screen.cpp, ItemArray.h, ItemArray.cpp, Item.h and Item.cpp to your project.

    GraphFX.h, GraphFX.cpp, Screen.h, and Screen.cpp implement the View and Drawing code.

    The screen class is responsible for drawing the screen (as the name suggests) the drawing code for the bars text etc, is found in CItem (each item is responsible for drawing itself).

    Next add the view header file to your projects view header file

    #include "GraphViewFX.h"

    Then derive your view from CGraphViewFX.

    class CGraphView : public CGraphViewFX

    Nice and easy!

    ItemArray.h, ItemArray.cpp and there names states, is a container for the CItem objects.

    Item.h and Item.cpp contain the numerical information. 

    I've set my own array of items to show as example.

    The OnDraw function in your own view must call the CGraphViewFX::OnDraw base class implentation first - see code.

    The CGraphFX class is responsible for Scrolling, Drawing and Hit-testing the items on the page - see code.

    You can add your own functionality to CItem to expand on what I have created here, ideally CItem would be a base class.

    That's it - I hope you like.

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    Written By
    Software Developer (Senior) Software Kinetics
    United Kingdom United Kingdom




    Software Kinetics
    are experts in developing customised and bespoke applications and have expertise in the development of desktop, mobile and internet applications on Windows.


    We specialise in:

    • User Interface Design
    • Desktop Development
    • Windows Phone Development
    • Windows Presentation Framework
    • Windows Forms
    • Windows Communication Framework
    • Windows Services
    • Network Applications
    • Database Applications
    • Web Development
    • Web Services
    • Silverlight
    • ASP.net


    Visit Software Kinetics

    Comments and Discussions

     
    GeneralNice Pin
    Jon Sagara26-Sep-01 21:49
    Jon Sagara26-Sep-01 21:49 
    QuestionHow to implement a line graph using MFC Pin
    13-Aug-01 5:28
    suss13-Aug-01 5:28 
    AnswerRe: How to implement a line graph using MFC Pin
    NormDroid18-Sep-01 22:18
    professionalNormDroid18-Sep-01 22:18 
    AnswerRe: How to implement a line graph using MFC Pin
    shani_pk6-Sep-04 11:06
    shani_pk6-Sep-04 11:06 
    AnswerRe: How to implement a line graph using MFC Pin
    vikas amin11-Aug-05 1:31
    vikas amin11-Aug-05 1:31 
    AnswerHow to implement a graph(Gaussian Curve) using MFC Pin
    Ritesh Karkele24-Aug-05 19:03
    Ritesh Karkele24-Aug-05 19:03 
    GeneralDoesnt work on docking window tab ctrl ! Pin
    vincent leong10-Jul-01 17:08
    vincent leong10-Jul-01 17:08 
    GeneralProblem first time I use it. Pin
    23-Feb-01 14:30
    suss23-Feb-01 14:30 
    This code looks very cool.

    When I download, unzip and then load the demo project, I get the following error:

    'Code page 1252 is required to support a English (U.K.) language resource in this file. See the "Multiple Language Resource Files" topic in the Miscellanoeous section of the READ. Unable to open this file.'

    The visual c++ compiler, then doesn't load the resources into a workspace.

    Is there any simple way I can resolve this?

    Please, any response you can give me will be greatly appreciated.

    Sincerely,
    Erich J. Ruth
    GeneralUpdate Item Pin
    Darren Schroeder11-Nov-00 4:22
    Darren Schroeder11-Nov-00 4:22 
    GeneralRe: Update Item Pin
    Dan Madden13-Nov-00 18:21
    Dan Madden13-Nov-00 18:21 
    GeneralProblem... Pin
    Joseph Dempsey9-Nov-00 15:32
    Joseph Dempsey9-Nov-00 15:32 
    GeneralRe: Problem... Pin
    NormDroid9-Nov-00 21:28
    professionalNormDroid9-Nov-00 21:28 
    GeneralAsk, and you shall receive! Pin
    Dan Madden8-Nov-00 6:45
    Dan Madden8-Nov-00 6:45 

    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.