Hi, when should i use refresh and when i should use invalidate? i found some code as follows in my app.
#If TargetMacOS Then
vCanvas.Refresh
#elseIf TargetWin32 Then
vCanvas.Invalidate
#ENDIF
Use invalidate unless you need the update to happen instantly (say you’re performing an animation or such).
thanks… so i should used invalidate for win and mac. mine is use to just show image… not animation
99% of the time, invalidate is correct. You should also use Canvas.Invalidate(Canvas.EraseBackground) to do the invalidate with the same erase background behavior as the canvas’s property. On Windows, for example, DoubleBuffer should be true and EraseBackground false, but Refresh and Invalidate default to triggering a background erase regardless, which will cause flicker.
Refresh should only be used when the Paint needs to happen during the execution of another event. This is a rare requirement, so treat invalidate as the normal behavior, and refresh as the special case.
thanks sam and thom for explaining to me.