I think it is much easier than what you have laid out.
oldCurs = system(_lastCurs) CURSOR(_arrowCursor) DEF LPRINT LONG IF PRCANCEL = 0 CURSOR (_PrinterCursor) LONG IF gNameWorld& CALL GETGWORLD(currPort&,currDevice&) CALL SETGWORLD(gNameWorld, currDevice&) CALL SETRECT(srcT,0,0,gRosterH,gRosterV) pHndl& = USR GETPICT(srcT) CALL SETGWORLD(currPort&,currDevice&) ROUTE _toPriner PICTURE (0,0),pHndl& DEF DISPOSEH(pHndl&) END IF END IF CURSOR oldCursNote : Untested code. I just typed it in.
Problems with original stuff...
- The printer uses a separate device record from the screen or Gworlds - "LONG IF gNameWorld& AND currPort&" doesn't work as you would expect. It would have needed to be LONG IF gNameWorld& <> 0 AND currPort& - Lock pixels is not required in the sample I used.
Try something like this.
Before your ROUTE _toPrinter line, do a pictHndl& = FN OPENPICTURE (rect) and then copybits the gworld into the same gworld it's already in (source and destination the same). Then CLOSEPICTURE. That should leave you with a PICT handle of the gWorld. Now do your ROUTE _toPrinter and then PICTURE (0,0), pictHndl& with pictHndl& being the handle you just got from the OPENPICTURE / CLOSEPICTURE.
Al Staffieri Jr.
.I believe (after ROUTE _toPrinter) you should
(1) obtain the window pointer to the printer window using
prtWndPtr& = WINDOW(_wndPointer)(2) calculate the the target rect where the gWorld will appear
(3) then set the gworld
CALL SETGWORLD(prtWndPtr&, 0)(4) use copybits as in
CALL COPYBITS(#myGworld&+2,#prtWndPtr&+2,myGwT,PrtrT,_srcCopy,0)I'm not sure if you are able to/must lock the printer window....
I usually convert the gWorld to a Picthandle&....
I go back and forth between PICT's and Gworlds thusly (Using the PG:PRO RdWr module:)
(I always use 32 bit GWorlds, that way I don't have to track bit depth, my customers have a minimum of 128MB of RAM installed, most have more RAM and anyway 90%+ of the images they deal with are in 32 bit color....)
CLEAR LOCAL LOCAL FN PICTfromGW&(aGW&) DIM aGwRect;0, aGwT%, aGwL%, aGwB%, aGwR% DIM PixMap&, aPictHandle&, oldWorld&, oldDevice& DIM aGwWide%, aGwHigh% LONG IF aGW& FN RdWrGetWorld(oldWorld&,oldDevice&) PixMap& = [[aGW&+2]] aGwT%;8 = PixMap& + _Bounds aGwWide% = aGwR% - aGwL%: aGwHigh% = aGwB% - aGwT% LONG IF (aGwWide% > 0) AND (aGwHigh% > 0) aPictHandle& = FN OPENPICTURE(aGwT%) LONG IF aPictHandle& FN RdWrLockWorld(aGW&) FN RdWrSetWorld(aGW&,0) CALL COPYBITS(#aGW&+2,#aGW&+2,aGwT%,aGwT%,_srcCopy,0) CALL CLOSEPICTURE FN RdWrUnlockWorld(aGW&) FN RdWrDisposeWorld(aGW&) END IF END IF FN RdWrSetWorld(oldWorld&,oldDevice&) END IF END FN = aPictHandle& CLEAR LOCAL LOCAL FN GWfromPICT&(aPictHandle&) DIM aGW&, myErr% DIM aGwRect;0, aGwT%, aGwL%, aGwB%, aGwR% DIM aPictRect;0, aPictT%, aPictL%, aPictB%, aPictR% DIM pictWide%, pictHigh%, oldWorld&, oldDevice& LONG IF aPictHandle& aPictRect;8 = [myPICT&]+_picFrame pictWide% = aPictR% - aPictL%: pictHigh% = aPictB% - aPictT% LONG IF (pictWide% > 0) AND (pictHigh% > 0) aGwT% = 0: aGwL% = 0: aGwB% = pictHigh%: aGwR% = pictWide% aGW& = FN RdWrColorWorld(aGwT%,32,0) LONG IF aGW& FN RdWrGetWorld(oldWorld&,oldDevice&) FN RdWrLockWorld(aGW&) FN RdWrSetWorld(aGW&,0) myErr% = FN HLOCK(aPictHandle&) CALL DRAWPICTURE(aPictHandle&,aGwRect) myErr% = FN HUNLOCK(aPictHandle&) CALL KILLPICTURE(aPictHandle&) FN RdWrUnlockWorld(aGW&) FN RdWrSetWorld(oldWorld&,oldDevice&) END IF END IF END IF END FN = aGW&