Page 1 of 1
TPrintPreview and API ?!!!

Posted:
February 4th, 2008, 7:35 am
by Sezar
I use Drawtext function to draw a string on the print preview canvas.
- Code: Select all
DrawText(PrintPreview.Canvas.Handle,PChar(MyText),-1,Rect(x,,x,x,x),dwflag);
but it doesn't work!
how can I draw a string with specified format on the TPrintPreview.Canvas?

Posted:
February 4th, 2008, 3:25 pm
by P_G
Hi Sezar,
you have to call 'BeginDoc' to get access to the canvas. After your DrawText-command just finish with 'EndDoc'.
regards, P_G
TPrintPreview and API ?!!!

Posted:
February 5th, 2008, 12:51 pm
by Sezar
thanks for your reply.
I've tested your instructions,but it doesn't work!
only way to print a text on the TPrinPreview.Canvas is using "TextOut" method,but it can not draw a formatted text!

Posted:
February 5th, 2008, 2:57 pm
by P_G
Textout is fine. You can format your text by doing something like this:
- Code: Select all
PrintPreview1.BeginDoc;
PrintPreview1.Canvas.Font.Color := clred;
PrintPreview1.Canvas.Font.Size := 12;
PrintPreview1.Canvas.Font.Name := 'Arial';
PrintPreview1.Canvas.Font.Style := [fsBold, fsItalic];
PrintPreview1.Canvas.TextOut(10,10, 'Test');
PrintPreview1.EndDoc;
regards, P_G

Posted:
February 5th, 2008, 3:57 pm
by Kambiz
You CAN use DrawText.
Does the passed rectangle contain the correct coordinates?