Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Real time graph in MFC

Options
  • 04-03-2003 6:19pm
    #1
    Closed Accounts Posts: 260 ✭✭


    Anyone know how to do this or if there is a free library to enable
    u to graph a line graph similar to the CPU history graph in
    windows task manager
    I want to pass a value from a loop and this value to be the next
    point on the graph
    Sounds easy but i cant do it :(
    Any help is appreciated


Comments

  • Registered Users Posts: 4,676 ✭✭✭Gavin


    Whack up your test code there and i'll see if I can give you a hand.

    Gav


  • Closed Accounts Posts: 28 Gav_b


    I did somthing like that recently, hope this helps :)

    Add a picture control to your dialog box, setting its property as type "frame" and then assign a control varible using the class wizzard, say m_filframe.
    Next your going to have to draw a box, into which you are then going to add lines or what ever you need for the graph, here's some code I wrote to do so:

    //create dc (see msdn)
    CClientDC dc(&m_filframe);
    //draw background box, passing a width and heigth
    dc.FillSolidRect(0,0,Width,Heigth,RGB(51,51,51));

    CPen pen; //create pen your going to draw the graph with
    pen.CreatePen( PS_SOLID, 1, RGB(115,189,255));
    //select the pen to start drawing
    dc.SelectObject(&pen);

    Once you have this done you are ready to start drawing, there are lots of function for doing lines and various shapes eg:

    dc.LineTo(point1,point2);

    The points will be relative to the top left corner of the rectangle you drew at the start.
    To get the graph to update the drawing with new values and repaint it, your going to need a thread or a timer, if you send me an email, I have some source code for a bouncing ball program that will show you how to do this.
    Gavin.


Advertisement