On Feb 15, 2006, at 6:00 PM, Joe Huber wrote:

NEVER use Refresh to force the canvas to refresh itself. Refresh will first erase the canvas and a short time later the Paint event will fire. And while your app is working on doing the redrawing, the canvas is sitting there EMPTY. This is what causes the flicker.

On OS9 and windows systems it's best to do all your drawing to a picture and then draw the finished picture to the canvas in one call to DrawPicture. This way the screen is never erased, it's never blank, it just goes instantly from the old image to the new image.

If you hang onto this picture, you can use it in the Paint event to flickerlessly update the canvas if RB should ever ask you to.

In summary, think of the Paint event as simply REDRAWING what was already showing, and use your own graphics.Draw calls to CHANGE what should be shown.

And don't ever call Refresh...it's almost as evil as DoEvents. :-) Just kidding, but it's close.

I guess if you do not know how to do it, then Refresh could be considered evil (or at least have unexpected results).

For one thing, if you call Refresh(False) then the background will *not* be erased thereby eliminating the flickering. But you can only use Refresh(False) when you are not dealing with transparency effects underneath the canvas.

The second point is that both Brad and I have overridden the Refresh and RefreshRect methods, changing the order in which it processes the request. Here is my method:

Sub Refresh(EraseBackground As Boolean = True)

// ======================================================================== ============
  '
' Refresh() deletes the existing buffer and calls Paint() to redraw the entire ' buffer. EraseBackground determines whether the background is erased before ' the new buffer image is drawn to the screen (required for transparency effects).
  '
' This class overrides the Super.Refresh() method but retains almost the exact ' behavior including EraseBackground default to True. What is different is that ' the order of method calls is designed to bring screen flickering to an absolute ' minimum. What this means is that the new buffer picture is always built before ' the background is erased and so the only thing left to do is to draw the buffer ' to the screen. Again like the regular Refresh() version, if you call Refresh(False) ' then the buffer will draw directly to the screen without first erasing the
  '    background.
  '
// ======================================================================== ============

If isBuffered Then // False for any OS X version, True for all others NewBuffer // method to create new Picture buffer object "mBuffer" Paint(mBuffer.Graphics) // new Paint() Event defined BufferedCanvas class Super.Refresh(EraseBackground) // finally calls the Super.Refresh()
  Else
    Super.Refresh(EraseBackground)
  End If

End Sub

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to