CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2013
    Posts
    3

    Help implementing real time graph with c code.

    Hi,

    I'm an electrical engineering student and have basic knowledge of programming. I was assigned a project to implement a real time graph to an application which continuously outputs data numerically through the GUI. The application that was created to do this is written in C.

    I have to turn those numerical numbers into a graphical display that is periodically updated to appear as real time.

    My adviser suggested using NTgraph (http://www.codeproject.com/Articles/...ctiveX-Control). I had no clue how to implement this to my code and was finally able to understand that the .OCX needs to be registered as a COM and then imported to the application using visual studios. However, I get an error when I try importing it since it is in C (Visual Studios 8) and not an MFC application.

    So my question is if it would be possible to implement the ActiveX control to my application even though it is not an MFC application and how to go about it. Or if you can recommend me another way to implement the real time graph with other graphical packages or how I can go about it in C.

    Any help is greatly appreciated. Thanks.

  2. #2
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Help implementing real time graph with c code.

    Quote Originally Posted by cordero2 View Post
    I had no clue how to implement this to my code and was finally able to understand that the .OCX needs to be registered as a COM and then imported to the application using visual studios. However, I get an error when I try importing it since it is in C (Visual Studios 8) and not an MFC application.
    Importing ActiveX has nothing to do with MFC. #import is intended to work with C++. So what you need is adding to your C project a .CPP file that would be a unit where you import the ActiveX. At the same time the unit must implement an interface to the rest of your C source code, i.e. the corresponding .H file must expose only extern "C" functions.
    Best regards,
    Igor

  3. #3
    Join Date
    Nov 2013
    Posts
    3

    Re: Help implementing real time graph with c code.

    Hi Igor,

    Thanks for the reply. I will try and implement the suggestion this week. Thank you.

  4. #4
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Help implementing real time graph with c code.

    I am slightly confused though.

    You say you are a student in electrical engineering, yet you are given a task for a programmer.
    You also say you have "basic knowledge of programming", but writing a program like this is not something a novice can do, It would require at least a good knowledge of the programming language, as well as a good understanding of how GUI programs are created on Windows. Potentially also having a good understanding of an application framework since GUI apps are rarely written on the raw windows SDK but typically are built on top of a framework like MFC, Qt, or any one of the many other options out there.

    This task also seems to add COM to the story which is yet another concept you have to at least grasp. A component based language like VB/C# might lessen the load here, but that assumes you are already knowledgeable in those. Both COM, Windows GUI and framework "sort of" imply the use of C++ rather than C.

    While you certainly can do this in C. It's adding another few layers of complexity on this.

  5. #5
    Join Date
    Nov 2013
    Posts
    3

    Re: Help implementing real time graph with c code.

    Hi OReubens,

    The project involves a hardware component that I have been able to finish and a software component that was written by another student that has graduated already. I was able to follow the logic of the program and edit components that have been incorrectly implemented. However, my professor wants me to implement the real time graph as an extra visually pleasing and verifying part of the project. Its not mandatory as I can already retrieve the data, save it to a .txt and graph it offline. However, having a real time graph would be beneficial to the project I am working on.

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Help implementing real time graph with c code.

    Quote Originally Posted by cordero2 View Post
    ... However, having a real time graph would be beneficial to the project I am working on.
    Instead of getting familiar with COM etc., for this task I would take a simple route and implement basic drawing using Win32 GDI.
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  7. #7
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Help implementing real time graph with c code.

    Quote Originally Posted by cordero2 View Post
    The project involves a hardware component that I have been able to finish and a software component that was written by another student that has graduated already. I was able to follow the logic of the program and edit components that have been incorrectly implemented.
    Would have helped stating this in the first place.

    What is this application written in ? What framework does it already use ? Is it already a GUI program or is it console based ?
    I largely agree with Vladimir, unless there's a good reason not to, it's probably going to be easier for you to do the graph in GDI rather than use COM (unless you already know how to use COM).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured