Discussion:
How to stop blinking in drawing with high data
(too old to reply)
ElectronicMan
2007-02-04 20:06:00 UTC
Permalink
Hello I have an application that receives about 1000 points/sec and draws
them as x.y graphs. I usually want to update view whenever a new data is
received. Of course many data points will overlap each other and won’t be
visible to user but whenever a new point is visible to user I want software
draws it. When I use SendMessage command whenever a new point is arrived to
redraw the whole view, application blinks catastrophically especially after a
few hours that I have millions of points. What can I do so on arrival of a
new point if it can change the view, it will be visible to user otherwise it
won’t bother redrawing the view. thanks
Drew
2007-02-05 16:46:36 UTC
Permalink
http://www.codeproject.com/gdi/flickerfree.asp
Post by ElectronicMan
Hello I have an application that receives about 1000 points/sec and draws
them as x.y graphs. I usually want to update view whenever a new data is
received. Of course many data points will overlap each other and won't be
visible to user but whenever a new point is visible to user I want software
draws it. When I use SendMessage command whenever a new point is arrived to
redraw the whole view, application blinks catastrophically especially after a
few hours that I have millions of points. What can I do so on arrival of a
new point if it can change the view, it will be visible to user otherwise it
won't bother redrawing the view. thanks
Harold Jimenez
2007-02-19 19:50:23 UTC
Permalink
Post by ElectronicMan
Hello I have an application that receives about 1000 points/sec and draws
them as x.y graphs. I usually want to update view whenever a new data is
received. Of course many data points will overlap each other and won’t be
visible to user but whenever a new point is visible to user I want software
draws it. When I use SendMessage command whenever a new point is arrived to
redraw the whole view, application blinks catastrophically especially after a
few hours that I have millions of points. What can I do so on arrival of a
new point if it can change the view, it will be visible to user otherwise it
won’t bother redrawing the view. thanks
Try using a memory device context, use CreateCompatibleDC from your current
DC and use this as a temporarily area for storing your drawing, also try
invalidating only the area that have changed (use InvalidateRect) so you
won't need to repaint the entire area in memory. After drawing your points,
flush the memory device context to the primary using BitBlt. Also use
CClientDC instead CPaintDC becaues CPaintDC is suitable for synchronized
painting events and not for custom. If you meet all the above steps, you will
kill flickering.

As a tip, try to save your in memory device context so when another window
moves over yours or when you minimize your drawing window (and no new points
have yet arrived), you just need to perform the BitBlt again to keep your
drawing, this speeds up the response of your graphics.

And as a last tip, you could think of resetting a timer (set to for instance
2 seconds) everytime the WM_PAINT message arrives so your app will only
redraw your in memory points when the timer reaches its time (don't forget to
kill the timer). You can show a message (like 'Please wait, regenerating
drawing...') on your window when no drawing is available (when the timer is
re-triggered). Once the timer tiggers, do your painting as explained above.
Loading...