How to Handle TPrinterCanvas

Please discuss general Delphi programming topics here.

How to Handle TPrinterCanvas

Postby Sezar » February 1st, 2008, 5:29 pm

Hello
I have drew on Printer.Canvas,I want to render it in a bitmap file.
I have assigned it to a TCanvas.
then I use BitBlt API Function to copy it in a TBitmap.
but it doesn't work?!!!
how can I do this? :-k
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby Johnny_Bit » February 2nd, 2008, 6:02 am

you don't have to assign that canvas to anything. it's already there. you just use it.
Thou shalt write the code, not connect the bricks.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

TPrinterCanvas

Postby Sezar » February 2nd, 2008, 7:30 am

I want to use it,but when I want to draw it,I get this message:
Code: Select all
Canvas doesn't allow drawing


and it seems that nothing are on that canvas!!!
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby Johnny_Bit » February 2nd, 2008, 3:45 pm

before you try anything you have to call begindoc and after everything call enddoc. should work fine
Thou shalt write the code, not connect the bricks.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

you can use follow code:

Postby john123 » February 3rd, 2008, 5:30 am

Code: Select all
Var
  Bitmap: TImage;
  X, Y: Smallint;
begin
  //Printer.PrinterIndex:= 0;//Select Printer
  Printer.BeginDoc;
  Bitmap:= TImage.Create(Self);
  Bitmap.Picture.LoadFromFile('c:\test.bmp');
  try
    Printer.Canvas.Draw(X, Y, Bitmap.Picture.Graphic);
  finally
    Printer.EndDoc;
  end;
end;
john123
Active Member
Active Member
 
Posts: 15
Joined: November 7th, 2007, 10:43 am

TPrinterCanvas

Postby Sezar » February 3rd, 2008, 1:36 pm

Thanks for your replies...

I think, I couldn't describe my problem!

I want to Copy the Contents of Printer.Canvas into a TCanvas.
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby john123 » February 3rd, 2008, 2:18 pm

printer canvas is write-only.
solution:
you can use replacement TCanvas & copy content by copyrect to Printer.Canvas
john123
Active Member
Active Member
 
Posts: 15
Joined: November 7th, 2007, 10:43 am


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 16 guests

cron