I am currently making a dialog based application in visual c++ 2010 where a chart is going to plot data coming in from an external source. My issue is that I am unsure how to import that data in real time to my application.

Does anyone have ideas?


4 Years
Discussion Span
Last Post by Ancient Dragon


It is actually data coming in through an ethernet connection. I have created a function that reads and writes data through the connection, however I am unsure how to interface it with the application.


Since we know nothing about your program, that function, or the data it is impossible for anyone to help you with this. You'll have to be a lot more specific and probably post some code. Out of all the data that you get from the socket you have to figure out what it is that you want your dialog program to plot, then save the data into some sort of circular buffer so that the dialog program can read it. As for where to put that function, I'd put it in another thread so that it can do it's thing without blocking the dialog program, and vice versa.

Edited by Ancient Dragon


Ok, the data that will be coming in will be made up of 8 ASCII characters. This is processed by the function shown below and is done once a second.

bool ReadData
    char*               buffer,
    unsigned long       bufferLength,
    unsigned long*      pReceiveLength
    unsigned long       regAddress;
    unsigned long       dataLength;

    // How many characters to read?
    regAddress = REG_SIO_RX_LENGTH;
    if (PvRegisterRead(GCamera.Handle, 1, &regAddress, &dataLength, NULL) != ePvErrSuccess)
        return false;

    // It must fit in the user's buffer.
    if (dataLength > bufferLength)
        dataLength = bufferLength;

    if (dataLength > 0)
        // Read the data.
        if (!ReadMem(GCamera.Handle, REG_SIO_RX_BUFFER, buffer, dataLength))
            return false;

        // Decrement the camera's read index.
        regAddress = REG_SIO_RX_LENGTH;
        if (PvRegisterWrite(GCamera.Handle, 1, &regAddress, &dataLength, NULL) != ePvErrSuccess)
            return false;

    *pReceiveLength = dataLength;

    return true;

Once received I want to pass the data to my chart whigh will update itself with the new point. I am using a charting control (High-speed-Charting-Control) that manages all chart related details.

My problem is that I am unsure where I place the call to the ReadData() function. Do I initialise a input stream in OnInitDialog?


In VC2003 drag and drop thing does not work, but you can do it in reverse. Open second project resource file in first project. And use Copy/Paste context menus to copy dialog resources from first project into second one, then save the file.


What kind of graph do you want? Line, pie, bar, or something else? Whatever it is, I suspect you will have to modify that charing program you found on codeproject.com to fit your needs. It expects to receive a bunch of data all at once and chart it. What you are trying to do is dribble a little bit into it evey second, something like a machine that continuously produces a real-time sign wave.

That control was written with VC6.0, there have been a lot of changes to MFC between that version and the compiler you currently use. Consequently it's going to require you to make some changes to the control's code. I assume you have VC++ 2010 Professional or better.


I am wanting to create a line graph with the incoming data and at this stage I have the charting program functioning.

I have VC++ 2010 ultimate so there shouldn't be any limitations in terms of the compiler.

Is the correct method to start a worker thread in OnInitDialog() which will then call the ReadData() function?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.