
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
Set page layout
This seems to be discouraged as a violation of the HIG, and when I had a need to do the same thing once, I could find no definitive documentation on how to do it. _If_ you can count on your users always using the same printer, then you can save as a resource a copy of the Print Record which has that particular printer in landscape mode; and then replace the current Print Record with your "saved" version when it comes time for you to force landscape mode.
In my case, I could not predict what printer my users would use, so I ended up doing this instead: first, I _detected_ whether landscape mode was already set (that's easy enough to do), and then, if it was not set, I'd display an alert advising the user they'd better switch to landscape mode or portions of their printout might get chopped off.
You can determine whether landscape mode is set by calling FN IsLandscapeSet, given below. (Another, "unofficial" but easier way to do it is to check the dimensions of the printer page rectangle from the Print Record. If the rectangle is wider than it is tall, it's a pretty safe bet that the user has selected landscape mode.)
'------------- Constants
_getRotnOp = 8 'for FN PrGeneral
'------------- Record Def's
DIM RECORD TGetRotnBlk
DIM iOpCode%
DIM iError%
DIM mylReserved&
DIM myhPrint&
DIM fLandscape.1
DIM bXtra.1
DIM END RECORD .TGetRotnBlk
'------------- Functions
'--------------------------
LOCAL FN PrOpen
` MOVE.L #$C8000000,-(SP)
` DC.W $A8FD
END FN
'--------------------------
LOCAL FN PrClose
` MOVE.L #$D0000000,-(SP)
` DC.W $A8FD
END FN
'--------------------------
LOCAL FN PrGeneral(pDataAddr&)
` MOVE.L ^pDataAddr&,-(SP)
` MOVE.L #$70070480,-(SP)
` DC.W $A8FD
END FN
'--------------------------
LOCAL FN PrError
DIM theError
` CLR.W -(SP)
` MOVE.L #$BA000000,-(SP)
` DC.W $A8FD
` MOVE.W (SP)+,^theError
END FN = theError
'--------------------------
LOCAL FN PrSetError(iErr)
` MOVE.W ^iErr,-(SP)
` MOVE.L #$C0000200,-(SP)
` DC.W $A8FD
END FN
'--------------------------
LOCAL FN IsLandscapeSet
'Returns one of the following:
'-1: Landscape mode is set
' 0: Landscape mode is not set
' 1: Can't tell whether it's set (driver doesn't support request)
DIM pData.TGetRotnBlk, landscape
FN PrOpen '(in case DEF PAGE wasn't done yet)
pData.iOpCode = _getRotnOp
pData.myhPrint& = PRHANDLE
FN PrGeneral(@pData)
SELECT CASE FN PrError
CASE _noErr
landscape = (PEEK(@pData + _fLandscape) <> 0)'(0 or -1)
CASE _resNotFound
'This printer driver doesn't support PrGeneral
landscape = 1
FN PrSetError(_noErr)
CASE ELSE
'_getRotnOp not supported
landscape = 1
END SELECT
FN PrClose '(to balance PrOpen)
END FN = landscape
'--------------------------
|