TPrintPreview and API ?!!!

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

TPrintPreview and API ?!!!

Postby Sezar » February 4th, 2008, 7:35 am

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?
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby P_G » February 4th, 2008, 3:25 pm

Hi Sezar,
you have to call 'BeginDoc' to get access to the canvas. After your DrawText-command just finish with 'EndDoc'.

regards, P_G
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

TPrintPreview and API ?!!!

Postby Sezar » February 5th, 2008, 12:51 pm

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!
Sezar
Sezar
Junior Member
Junior Member
 
Posts: 42
Joined: April 18th, 2007, 4:40 pm
Location: Mashhad,Iran

Postby P_G » February 5th, 2008, 2:57 pm

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
P_G
Senior Member
Senior Member
 
Posts: 51
Joined: June 14th, 2004, 11:13 am
Location: Germany

Postby Kambiz » February 5th, 2008, 3:57 pm

You CAN use DrawText.

Does the passed rectangle contain the correct coordinates?
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 4 guests

cron