FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Method print() TWindow = diferences between Laser x Deskjet
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Method print() TWindow = diferences between Laser x Deskjet
Posted: Wed Aug 20, 2008 04: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 ?


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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Method print() TWindow = diferences between Laser x Deskjet
Posted: Wed Aug 20, 2008 05: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.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Method print() TWindow = diferences between Laser x Deskjet
Posted: Wed Aug 20, 2008 07:49 PM
Hello Mr.James, thanks for your suport !

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

In fact the :Hardcopy() calls :-)rint() internally...

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

And I try this way too:

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
Yury Marcelino Al
yury030575@yahoo.com.br
vimansca@vimansca.com.br
Leme / SP - Brasil
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Method print() TWindow = diferences between Laser x Deskjet
Posted: Wed Aug 20, 2008 08: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 56
Joined: Wed May 23, 2007 02:01 PM
Method print() TWindow = diferences between Laser x Deskjet
Posted: Thu Aug 21, 2008 06:43 PM
Hello Mr.James,

I try this way:

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

Continue the discussion