How do I stop FireMonkey TPaintBox from erasing its background?

  

A TCanvasGPU is used for mobile platforms on FireMonkey. Unfortunately, as someone discovered: FMX on iOS: how to perform partial invalidation? , this canvas does not support cliprects and Canvas.InvalidateRect(TRectF) always invalidates the whole canvas.

This wouldn’t be so bad, except that the canvas background is always erased before an OnPaint event. Which means any attempt to update just a rectangle in an OnPaint is doomed, as the whole area is cleared first. So even the smallest update requires the entire canvas be drawn.

Does anyone know if it’s possible to stop a control (specifically TPaintBox) background being erased in FireMonkey? It used to be possible in VCL by setting ControlStyle := ControlStyle + [csOpaque].

I found TCustomForm.PaintBackground in FMX.Forms, made a local copy and commented out the call to this in TCustomForm.PaintRects, thinking it would stop controls being erased, but the TPaintBox canvas still got cleared somehow.

Comments are closed.