Author Topic: Clear canvas and set transparent  (Read 10697 times)


  • Guest
Clear canvas and set transparent
« on: April 14, 2011, 08:10:39 pm »
See the attached picture / Attached 7z file (requires BGRABitmap as installed package).

Compile and run lazgui_test.

If you go over the 'ToolButton' you will see that is painted.

But if you leave the 'ToolButton' area isn't cleared, and text is drawn over the previous drawing.

I need to clear the previous drawing and only draw text in a transparent area (to see the background gradient).

I tried to use ACanvas.Clear:

(lazguiwin7.pas line 60):
Code: [Select]
if AState = lgNormal then begin
    bmp:= TBGRABitmap.Create(ARect.Right,ARect.Bottom);
    ACanvas.Clear; // This clear the drawing, but isn't transparent, and used in this way produces flickering

But the background isn't transparent, it is filled with clDefault.
« Last Edit: April 14, 2011, 08:14:58 pm by lainz »


  • Hero Member
  • *****
  • Posts: 1621
Re: Clear canvas and set transparent
« Reply #1 on: April 14, 2011, 08:45:18 pm »
You are 'abusing' the paintboxes and assume that they work like controls.

The easiest fix: repaint all elements of the 'toolbar' when something changes and do it in the right order: first the 'toolbar paintbox' and then all 'button paintboxes'.

BTW: case statement  8)
All posts based on: Win10 (Win64); Lazarus 2.0.10 'stable' (x64) unless specified otherwise...


TinyPortal © 2005-2018