Recent

Author Topic: Problem Overriding the Content of PaintBox  (Read 7949 times)

andrejsilva

  • New Member
  • *
  • Posts: 14
Problem Overriding the Content of PaintBox
« 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

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Problem Overriding the Content of PaintBox
« Reply #1 on: April 27, 2010, 09:37:32 am »
Just do a Canvas.FillRect() with Brush=bsSolid and appropriate color.
Lazarus 1.7 (SVN) FPC 3.0.0

andrejsilva

  • New Member
  • *
  • Posts: 14
Re: Problem Overriding the Content of PaintBox
« Reply #2 on: April 27, 2010, 11:28:49 am »
Please could you post an example.

Thanks.

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: Problem Overriding the Content of PaintBox
« Reply #3 on: April 27, 2010, 02:00:54 pm »
Code: [Select]
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
Lazarus 1.7 (SVN) FPC 3.0.0

 

TinyPortal © 2005-2018