## printpreview with drawtext method ?

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

### printpreview with drawtext method ?

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
dav999
Active Member

Posts: 14
Joined: October 7th, 2003, 3:04 pm

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.
Kambiz

Kambiz

Posts: 2429
Joined: March 7th, 2003, 7:10 pm

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
Last edited by dav999 on June 27th, 2005, 2:11 pm, edited 1 time in total.
dav999
Active Member

Posts: 14
Joined: October 7th, 2003, 3:04 pm

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);
Kambiz

Kambiz

Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Yes i have seen , i use this in my 2nd line of the previous message

Thx
David
dav999
Active Member

Posts: 14
Joined: October 7th, 2003, 3:04 pm