imekon
imekon

Reputation: 1523

Why does clearing a canvas clear the parent canvas in Firemonkey?

If I do the following for a TPaintBox, I clear the parent control as well as the paint control:

canvas.BeginScene;
canvas.Clear(TAlphaColors.Gray);
canvas.EndScene;

If I switch to ClearRect, it then works correctly:

canvas.BeginScene;
canvas.ClearRect(TRectF.Create(0, 0, width, height), TAlphaColors.Gray);
canvas.EndScene;

I'm guessing it's because the paint box is sharing the parents canvas and clear works on that, but clear rect does the right thing. Can anyone confirm this?

Upvotes: 1

Views: 1115

Answers (1)

user3365085
user3365085

Reputation: 15

The paintbox inherits its canvas from the parent control. It simply implements paint methods. If you want something different, put e.g. a panel on and make that the parent of the paintbox.

Upvotes: 1

Related Questions