[futurebasic] Re: Carbon Printing

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2003 : Group Archive : Group : All Groups

From: "David A. Bailey" <dabs@...>
Date: Sat, 07 Jun 2003 22:09:43 -0700
My previous post was just a matter of faulty logic.  Here is a functioning
example of getting a page setup, storing it and displaying it at a later
time.

WINDOW 1,"",(0,0)-(500,240)
BUTTON  1,1,"Page Setup",(400,200)-(490,230),1

dim gMyPageFormat as ^^PMPageFormat'define my application stored page format
object
'you can define many page formats to tie them to different items to print

END GLOBALS


CLEAR LOCAL
dim @rslt,changed
dim as PMRect            tempPageRect
DIM t,l,b,r
'~'2
LOCAL FN DoMyPageSetup
'~'2
close lprint
IF gFBPrintSession  THEN rslt = fn PMRelease (gFBPrintSession)
IF gFBPageFormat    THEN rslt = fn PMRelease (gFBPageFormat)
IF gFBPrintSettings THEN rslt = fn PMRelease (gFBPrintSettings)

rslt = fn FBBeginSession

LONG IF SYSTEM(_sysvers) > 1000
rslt = fn PMSessionUseSheets (gFBPrintSession, WINDOW(_wndRef) , 0)'Use
sheets if we are system 10
end if

LONG IF gMyPageFormat = 0 and rslt == _noErr'first time we ask for a page
setup
rslt = fn 
PMSessionPageSetupDialog(gFBPrintSession,gFBPageFormat,changed)'display the
print setup
If rslt == _noErr then rslt = fn
PMFlattenPageFormat(gFBPageFormat,gMyPageFormat)'store our format record
xelse'all subsequent page setups
'~';
Call DisposePTR(gFBPageFormat)
gFBPageFormat = 0
'just to show we are using our record - not necessary for functionality
'~';
rslt = fn PMUnflattenPageFormat(gMyPageFormat,gFBPageFormat)'copy our record
to the opaque format record
rslt = fn PMSessionValidatePageFormat(gFBPrintSession,gFBPageFormat,changed)
If rslt == _noErr then rslt = fn
PMSessionPageSetupDialog(gFBPrintSession,gFBPageFormat,changed)'display the
print setup
If rslt == _noErr then rslt = fn
PMFlattenPageFormat(gFBPageFormat,gMyPageFormat)'store our format record
end if
'could use more error checking of rlst plus 'changed' will not equal 0 if
you change someing in the setup

rslt = fn PMGetAdjustedPageRect(gFBPageFormat,tempPageRect)'could also check
paper rect, orientatin, etc
t    = tempPageRect.top
l    = tempPageRect.left
b    = tempPageRect.bottom
r    = tempPageRect.right
def tab = 5
print %(10,30)"t","l","b","r"
print %(10,50)t,l,b,r," page rectangle in pix"
print
PRINT "Use Menu or Command Q to quit"

END FN = rslt


CLEAR LOCAL
dim evt
'~'2
LOCAL FN HandletheEvent
'~'2
evt = dialog(0)
IF evt = 1 THEN fn DoMyPageSetup
END FN


ON dialog FN HandletheEvent

do
handleevents
until 0