Excesive flickering on canvas


I just finished an app that has one canvas and 2 images on it. One of the images moves around the screen when the user presses the arrows on the keyboard or uses the mouse to drag.

The canvas uses the paint event to draw the pictures. On my mac it works wonderfully but on windows it just flickers. I used the GDI+ and even tried without it. Flickering is just horrendous.

This is the code that draws the picture

I need to eliminate the flickering. Any ideas?

Is it set to be double buffered ?
Not necessary on OS X but definitely is to reduce flicker on Windows

Eliminating flicker can be difficult.

• Make sure there are no overlapping controls on the canvas.
• Set doublebuffered = true
• Set EraseBackground = false
• Make sure any calls to Refresh have a false passed in to prevent the erase. Refresh(false)
• Make sure any calls to Invalidate have a false passed in to prevent the erase. Invalidate(false)

cool I will test these ideas. If not eliminated, certainly I want to reduce it. Will post my results here

Bob and Norman

Thanks for your advice. Actually the double buffer was part of the answer.
Mr. Keeney’s suggestion of not having overlapping controls on the canvas was also key. I did not realized that I had a control overlapping… Thanks to both now my app is working… mostly.

Set EraseBackground to False on each button, that solves it.