
FB II Compiler
PG PRO
Debugging
Memory
System
Mathematics
Resources
Disk I/O
Windows
Controls
Menus
Mouse
Keyboard
Text
Fonts
Drawing
Sound
Clipboard
Printing
Communication
ASM
|
PRINTING
Change the printer resolution
This is probably an old story but new to me. I'd like to get the printers max resolution and then set this for some high res graphics. The Toolbox way is through the procedure PrGeneral and some data structures. Course PrGeneral is not implemented in FBII, but it should be easy enough to do, pushing its parameter (a record address) on the stack and maybe the Selector number (or else in D0). My problem is the Trap is "_PrGlue", apparently a glue routine address that, according to IM's comments on glue routines, must be implemented by the compiler - Catch 22 or something. I'm hoping that there is some way around this
Bummer! I can't believe that PRGENERAL wasn't built in. Here is an untested substitute.
DIM RECORD TGnlData
DIM iOpCode%
DIM iError%
DIM lReserved&
DIM startOfPRData;0
DIM END RECORD .TGnlDataSz
LOCAL FN PRGeneral(@dataPtr&)
MACHLG &2F3C,&7007,&0480,&A8FD
END FN = USR PRERROR 'return result
Call with...
DIM myData.TGnlDataSz
err = FN PRGeneral(myData.nil%)
Thankyou Staz, this really helped :
I had to add a line to push address on stack, then wrote the following demo, in case anyone is interested. It really works to change printer resolution, at least on my LaserWriter. The TGetRslBlk would look different (see IM) but principle is same. Don't know about 3rd party printers.
DIM gPrHndl&
DIM RECORD TGnlData
DIM iOpCode%
DIM iError%
DIM iReserved&
DIM END RECORD.TGnlData
DIM RECORD TGetRslBlk
DIM TGD4.TGnlData 'always set = 4
DIM iRgType%
DIM minX%
DIM maxX%
DIM minY%
DIM maxY%
DIM iRslRecCnt%
DIM rgRslRec.108
DIM END RECORD.TGetRslBlk
DIM RECORD TSetRslBlk
DIM TGD5.TGnlData 'always set = 5
DIM printHndl&
DIM iXRsl%
DIM iYRsl%
DIM END RECORD.TSetRslBlk
END GLOBALS
LOCAL FN PRGeneral(dataPtr&)
` MOVE.L ^dataPtr&,-(sp)
MACHLG &2F3C,&7007,&0480,&A8FD
END FN = USR PRERROR 'return result
LOCAL FN getResolutions
DIM getRslData.TGetRslBlk
gPrHndl& = PRHANDLE
LONG IF gPrHndl&
DEF PRINTDEFAULT(gPrHndl&) 'set defaults in printRecord
byte = USR PRVALIDATE(gPrHndl&): PRINT "Validate =" byte
'byte = 0 indicates record is compatible with Print Manager
PRINT "Xres = " gPrHndl&..prInfo.iVres%;
PRINT " Yres = " gPrHndl&..prInfo.iHres%'both 72 dpi
addr& = VARPTR(gPrHndl&..prInfo.rPage.top%)
t;8 = @gPrHndl&..prInfo.rPage.top%
PRINT "page rect " t,l,b,r 'printed page size at 72 dpi
getRslData.TGD4.iOpCode% = 4
getRslData.TGD4.iError% = 0
GRErr = FN PRGeneral(@getRslData)
PRINT "GetRes Errors "GRErr, getRslData.TGD4.iError%
PRINT "print driver version "getRslData.iRgType%
PRINT "minX "getRslData.minX" maxX "getRslData.maxX
PRINT "minY "getRslData.minY" maxY "getRslData.maxY
ct = getRslData.iRslRecCnt%
PRINT ct " Resolution record";
IF ct > 1 THEN PRINT "s:" ELSE PRINT ":"
GRAddr& = @getRslData
FOR ctnum = 0 TO ct-1
PRINT {GRAddr&+20+ctnum*2}, {GRAddr&+22+ctnum*2}
NEXT ctnum
PRINT:PRINT
END IF
END FN
LOCAL FN setResolution
DIM setRslData.TSetRslBlk
setRslData.TGD5.iOpCode% = 5
setRslData.TGD5.iError% = 0
setRslData.printHndl& = gPrHndl&
setRslData.iXRsl% = 600 'must be in X range
setRslData.iYRsl% = 600 'same for Y
SRErr = FN PRGeneral(@setRslData)
PRINT "SetRes Errors "SRErr, setRslData.TGD5.iError%
LONG IF gPrHndl&
byte = USR PRVALIDATE(gPrHndl&): PRINT "Validate =" byte
PRINT gPrHndl&..prInfo.iVres%, gPrHndl&..prInfo.iHres%'new res
addr& = VARPTR(gPrHndl&..prInfo.rPage.top%)
t;8 = @gPrHndl&..prInfo.rPage.top%
PRINT "page rect " t,l,b,r 'new page rect size
ROUTE _toPrinter
CALL PENNORMAL 'show printing at high res
PLOT l,t TO r,b
CIRCLE r/3,(3*b)/4,r/4
TEXT _Geneva,(12*r)/552 'abt size of 12pt in default res
PRINT %(r/4,(3*b)/4) "Hello"
ROUTE _toScreen
CLOSE LPRINT
END IF
END FN
LOCAL FN initialize
WINDOW 1,"Show results",(0,0)-(400,300)
TEXT _Geneva, 12
DEF LPRINT
END FN
'---------------------------MAIN------------------------------
FN initialize
FN getResolutions
FN setResolution
DO
UNTIL FN BUTTON
END
|