PDA

View Full Version : PEGetSelectedPrinter - Has anyone had success with this.



Sean Bamforth
21-Mar-2005, 05:57 AM
I am trying to work out the orientation of a crystal report.
I'm doing this because we have a customer report that could be landscape or
portrait.

If you just print the report, it works fine.
If you take a landscape report, request a printer then print it, it prints
in portrait.
I can set the orientation of the WinQLSelectPrinter to be portrait or
landscape, but I can't find a way of asking which way the report should
print.

PEGetSelectedPrinter should do the job. It should return a DEVMode block.
However, this devmode block seems to contain incorrect information. See
below for my code.

My questions are -
Has anyone had the same problem and got it to work?
Does PEGetSelectedPrinter even work? Has anyone used it successfully.

My configuration is VDF7 and Crystal 8.

Thanks in advance for any info on this matter.

regards

Sean Bamforth



==========================================


The Code I'm using is as follows ....

Function ReportOrientation Returns String
Local Integer iPrintJob iResult iTextHandle iTextLength
Local String sDriver sPrinter sPort sDEVMODE sReturn
Local Pointer pDriver pPrinter pPort pDEVMODE pReturn
integer iOrientation
integer iFields
string sTmp
integer iTmp

Get PrintJob To iPrintJob
FillType PETextStructure With 0 To sDriver
FillType PETextStructure With 0 To sPrinter
FillType PETextStructure With 0 To sPort
FillType DevMode With 0 To sDEVMODE

GetAddress Of sDriver To pDriver
GetAddress Of sPrinter To pPrinter
GetAddress Of sPort To pPort
GetAddress Of sDevMode To pDEVMODE

Move
(PEGetSelectedPrinter(iPrintJob,pDriver,pDriver+4, pPrinter,pPrinter+4,pPort,
pPort+4,pDEVMODE)) To iResult
GetBuff From sDevMode at DEVMODE.dmFields to iFields
If (iFields iAnd DM_ORIENTATION) move (BytesToShort(sDevMode,45))
to iOrientation

showln "iFields, " iFields
showln iresult ", " (length(sDevMode)) ", " iOrientation ", "
iFields

Send HandlePossibleError
Function_Return iOrientation
End_Function // PrinterDEVMODE




--
===============================
SELECT Computer Systems Ltd.
sean@select-cs.co.uk