Page 1 of 1

printpreview with drawtext method ?

PostPosted: June 27th, 2005, 10:56 am
by dav999
Hello

in delphi for center a text in table, i use the Printer.DrawText method, but is missed in your great control :(

how i can use a method as implemented in tprintpreview, for center a text in a "virtual box" (for creating a table), but i would not use a rtf file/richedit control.

Thanks
David

ps : excuse for my poor english, but if anyone speak french :)

PostPosted: June 27th, 2005, 11:32 am
by Kambiz
Which version of Delphi are you using? From D1 to D7 there's no DrawText method for the Printer object.

Anyway, you can use DrawText function of Windows API for your purpose.

PostPosted: June 27th, 2005, 11:43 am
by dav999
Sorry

i work with Delphi 6 Pro and Xp SP1a

i have tested with this code but it's not good :
Code: Select all
drawtext(frm_depart.print.Handle,pchar('Clt'),length('Clt'),rect,DT_VCENTER or DT_CENTER);


edit :
ok i have seen my error, i have missed the canevas property in my previous line, the good line is :
Code: Select all
drawtext(frm_depart.print.Canvas.Handle,pchar('Clt'),length('Clt'),rect,DT_VCENTER or DT_CENTER);



Thx
David

PostPosted: June 27th, 2005, 1:33 pm
by Kambiz
So, you can do the same with canvas of PrintPreview:

Code: Select all
drawtext(PrintPreview.Canvas.Handle, 'Clt', -1, rect, DT_VCENTER or DT_CENTER);

PostPosted: June 27th, 2005, 2:10 pm
by dav999
Yes i have seen :roll: , i use this in my 2nd line of the previous message

Thx
David