Click to See Complete Forum and Search --> : OnPaint() PROBLEM???


June 2nd, 1999, 02:30 PM
HI,

Iam developing a VC+= application(client) which does plotting the values on the screeen getting values from the server VC++ app.The code for plotting values is written in OnPaint() function in client app. The communication between applications is through sockets.

I have a problem , when ever I switch between applications the OnPain() function in client app is getting called and it tries to replot from the beginning. Since the plot is to be done getting values at the real time the graph is getting distorted.Please let me know the solution for this.

Thanx

Ravi Bhavnani
June 2nd, 1999, 03:59 PM
Your OnPaint() handler should be very "dumb". That is, it shouldn't
perform any computations or other logic - it should just paint (render)
stuff on the screen.

The "stuff" you render should be stored in an array or list which continously
gets updated in a separate thread by communicating with your server
app. If you're not familiar with threads, you could just create a timer and
add the code to update the "stuff" in OnTimer().


OnTimer()
{
populate my_array[] with data;
Invalidate();
}

OnPaint()
{
traverse my_array[] and draw on the screen
}




/ravi