| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /* =================================================================
- file : printbins.p
- dd : 15.11.2006
- purpose : Returns an array of Printer Bins and Bin Names
- by : Ildefonzo Arocha
- usage : See Example below
- tested : Tested in Windows 2003 Server, OE 10.1A,
- Brother HL-1250,
- HP Color LaserJet 4550 and HP 4250 Tr.
- Note : Runs in earlier versions of Progress, just change
- the indeterminate array to something else of your choice
- (comma-delimited list, etc)
- ================================================================= */
- /********** Test Block *********/
- DEFINE VARIABLE iNumBins AS INTEGER NO-UNDO.
- DEFINE VARIABLE iaBinID AS CHARACTER NO-UNDO EXTENT.
- DEFINE VARIABLE caBinNames AS CHARACTER NO-UNDO EXTENT.
- DEFINE VARIABLE iBin AS INTEGER NO-UNDO.
- RUN GetPrinterBins( SESSION:PRINTER-NAME ,
- SESSION:PRINTER-PORT ,
- OUTPUT iNumBins ,
- OUTPUT iaBinID ,
- OUTPUT caBinNames ).
- REPEAT iBin = 1 TO iNumBins:
- DISPLAY
- iaBinID[ iBin ] " = " caBinNames[ iBin ] FORMAT "X(30)" .
- END.
- /********** End Test Block *********/
- PROCEDURE GetPrinterBins:
- DEFINE INPUT PARAMETER pcPrinterName AS CHARACTER NO-UNDO.
- DEFINE INPUT PARAMETER pcPrinterPort AS CHARACTER NO-UNDO.
- DEFINE OUTPUT PARAMETER piNumBins AS INTEGER NO-UNDO.
- /* Set our extent to 20 bins! Warning: Under windows, some printers
- allow you to define virtual bins for different types of papers, which
- means this procedure will return more bins than you expect */
- DEFINE OUTPUT PARAMETER piaBinIDs AS INTEGER NO-UNDO EXTENT 40.
- DEFINE OUTPUT PARAMETER pcaBinNames AS CHARACTER NO-UNDO EXTENT 40.
- DEFINE VARIABLE mBins AS MEMPTR NO-UNDO.
- DEFINE VARIABLE mBinNames AS MEMPTR NO-UNDO.
- DEFINE VARIABLE iTmp AS INTEGER NO-UNDO.
- &SCOPED MAXBINNAMESIZE 24
- &SCOPED WORD 2
-
- /* First get the number of bins, with it we correctly
- allocate enough memory for the arrays */
- RUN DeviceCapabilities( pcPrinterName ,
- pcPrinterPort ,
- 6 , /*DC_BINS*/
- 0,
- 0 ,
- OUTPUT piNumBins ).
- IF piNumBins < 1 THEN DO:
- piNumBins = 0.
- RETURN.
- END.
-
- /* mBins will be filled with an array of Bin IDs */
- SET-SIZE( mBins ) = piNumBins * {&WORD}.
- RUN DeviceCapabilities( pcPrinterName ,
- pcPrinterPort ,
- 6 , /*DC_BINS*/
- GET-POINTER-VALUE( mBins ),
- 0 ,
- OUTPUT piNumBins ).
-
- /* mBinNames is filled with an array of Bin Names */
- SET-SIZE( mBinNames ) = {&MAXBINNAMESIZE} * piNumBins.
- RUN DeviceCapabilities( pcPrinterName ,
- pcPrinterPort ,
- 12 , /* DB_BINNAMES */
- GET-POINTER-VALUE( mBinNames ),
- 0 ,
- OUTPUT piNumBins ).
-
-
- /* Parse our return values and store it in an easy to read array */
- DO iTmp = 0 TO piNumBins - 1:
- ASSIGN
- piaBinIDs[ 1 + iTmp ] = GET-SHORT( mBins , 1 + ( iTmp * {&WORD} ) )
- pcaBinNames[ 1 + iTmp ] = GET-STRING( mBinNames , 1 + ( iTmp * {&MAXBINNAMESIZE} ) ).
- END.
-
- SET-SIZE( mBins ) = 0.
- SET-SIZE( mBinNames ) = 0.
- END PROCEDURE.
- PROCEDURE DeviceCapabilities EXTERNAL "Winspool.drv":U:
- DEFINE INPUT PARAMETER pDevice AS CHARACTER.
- DEFINE INPUT PARAMETER pPort AS CHARACTER.
- DEFINE INPUT PARAMETER fwCapability AS LONG.
- DEFINE INPUT PARAMETER pOutput AS LONG.
- DEFINE INPUT PARAMETER pDevMode AS LONG.
- DEFINE RETURN PARAMETER pResult AS LONG.
- END.
|