Method print() TWindow = diferences between Laser x Deskjet

Method print() TWindow = diferences between Laser x Deskjet

Postby yury » Wed Aug 20, 2008 4:52 pm

Hi everyone !

This code below prints the dialog (obj is the parameter)...

In deskjet printer (300 dpi) works fine, but in laser printer (600 dpi) it´s not OK, the image on the paper is too small

It´s possible fixed this ?


Code: Select all  Expand view  RUN
FUNCTION Printer_Dlg(obj)

LOCAL oPrinter

oPrinter := PrintBegin(obj:cTitle,.T.,.F.,NIL,.T.)

SysRefresh()

IF EMPTY( oPrinter:hDC )
   RETURN
ENDIF

oPrinter:SetLandscape()

oPrinter:StartPage()

SysRefresh()

obj:Print(oPrinter)

oPrinter:EndPage()

ENDPRINT

RETURN


regards
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Postby James Bott » Wed Aug 20, 2008 5:18 pm

Yury,

This is from my notes.

James

-------------------------
The Hardcopy() method prints a graphic of the current window or dialog. Hardcopy is a method of TWindow. The syntax is:

oWnd:hardcopy( nScale, lUser )

There is no default for nScale. lUser defaults to .t. and calls up the printer setup dialog.

To call it from a dialog do:

oDlg:hardcopy(6, .f.)

The TWindows:hardcopy() method really should figure the default scale based on the resolution of the printer. Something like:

default nScale:= oPrn:nLogPixelX / 100

However here is a trick you can use to get the resolution of the current printer. Just define a temporary oPrn:

...ACTION (oPrn:=tprinter():new(),;
::hardcopy( int( oPrn:nLogPixelX()/100 ), .f. ), oPrn:end())

This won't work if you allow the user to select a printer by lUser being .t. (the default), so make sure you pass .f. Actually, it will still print but the scale will be off if the user selects a printer with a different resolution that of the current one.
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby yury » Wed Aug 20, 2008 7:49 pm

Hello Mr.James, thanks for your suport !

I get your trick, it´s OK, but the :Print() allow you pass the <nScale> parameter...

In fact the :Hardcopy() calls :Print() internally...

I try your sugestion, calls :Hardcopy with a parameter <nScale> of the default printer...

And I try this way too:

Code: Select all  Expand view  RUN
LOCAL oPrinter

oPrinter := PrintBegin( 'Testing', .T. , .F. , NIL , .T. )

SysRefresh()

IF EMPTY( oPrinter:hDC )
   RETURN
ENDIF

oPrinter:SetLandscape()

oPrinter:StartPage()

SysRefresh()

nScale = int(oPrinter:nLogPixelX()/100) 

obj:Print(oPrinter,,,nScale)

oPrinter:EndPage()

ENDPRINT


Unfortunately both don't work in Laser printer (prints a blank sheet), in Deskjet it´s OK...

Thanks for your help

Regards
Last edited by yury on Thu Aug 21, 2008 6:43 pm, edited 1 time in total.
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm

Postby James Bott » Wed Aug 20, 2008 8:03 pm

You said your original code was working but the scale was wrong, correct?

I found this is the syntax for the Print() method:

Print( oTarget, nRow, nCol, nScale )

So change your line to:

obj:Print(oPrinter, 1, 1, 6)

And see if that works on the Laser.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby yury » Thu Aug 21, 2008 6:43 pm

Hello Mr.James,

I try this way:

Code: Select all  Expand view  RUN
obj:Print(oPrinter, 1, 1, 6)


But don´t work, print a blank sheet...

I thank you very much your help, but I quit...

I will think other way to print the dialog/screen...

Thank you again

Regards
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
yury
 
Posts: 56
Joined: Wed May 23, 2007 2:01 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 41 guests