Lazarus
Programming => Packages and Libraries => Ported from Delphi/Kylix => Topic started by: andrejsilva on April 26, 2010, 04:59:57 pm
-
Hello
How do I clear the contents of a Paintbox, since the component I'm working on a preview to printing on dot-matrix, every time I change the contents of the paintbox page is a letter on top of another:
follows the code that loads the pages:
Hoja : TlmfImage; da unit LMF (Lazarus Metafile)
procedure TPrintPreview.ShowerPaint(Sender: TObject);
var
Rect : TRect;
begin
if DontDraw then
begin
Shower.Width := Round(Hoja.Width*FZoom/100)+10;
Shower.Height := Round(Hoja.Height*FZoom/100)+10;
DontDraw := False;
Exit;
end;
Rect.Left := 10;
Rect.Top := 10;
Rect.Right := Round(Hoja.Width*FZoom/100);
Rect.Bottom := Round(Hoja.Height*FZoom/100);
Shower.Width := Round(Hoja.Width*FZoom/100)+10;
Shower.Height := Round(Hoja.Height*FZoom/100)+10;
Shower.Canvas.StretchDraw(Rect,Hoja);
end;
Thanks
-
Just do a Canvas.FillRect() with Brush=bsSolid and appropriate color.
-
Please could you post an example.
Thanks.
-
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
with PaintBox1.Canvas do
begin
Brush.Color:=clBtnFace;
Brush.Style:=bsSolid;
FillRect(PaintBox1.ClientRect);
end;
end;
http://lazarus-ccr.sourceforge.net/docs/lcl/extctrls/tpaintbox.html
http://lazarus-ccr.sourceforge.net/docs/lcl/graphics/tcanvas.html