* :--------------------------------------- * ------------------------: Low Level Printer API Parameters * :--------------------------------------- * : This copybook is used for low-level * : Printer APIs supplied by GUI ScreenIO. * : * : For printing of basic reports you can * : use these APIs or our PrintFile API * : which automates many of these steps. * : * : These are LOW LEVEL APIs which require * : you to do all formating in the text * : you supply. Suitable for LinePrinter * : quality reports with the default fonts * : but capable of handling any embeded * : escape sequences you may supply. * : * : These APIs replace those provided by * : Microsoft or your Compiler and are * : Client/Server aware. Do not complain * : to us if your Compiler APIs are not * : able to function in a client/server * : environment. * : * : Specifically this copybook is used for * : the following APIs * : * : API-OPENPRINTER * : API-STARTDOCPRINTER * : API-STARTPAGEPRINTER * * : API-WRITEPRINTER * * : API-ENDPAGEPRINTER * * : API-ENDDOCPRINTER * : API-CLOSEPRINTER * : * : Note that the above sequence is the * : usual sequence of writing data to * : a windows printer, with the Asterisk * * : calls being repeated as many times as * : necessary to accomplish the print. * : * >>>>>>> : If you open a printer, be sure to * : close it. If you Start a document * : be sure to End it. If any API fails * : clean up with the next call at same * : INDENTED level in above list. * : * : Client Server Issues: * : These APIs will nornally run on the * : client side (printing on the client's * : printers). * : To force these APIs to run on the * : server, WIN32API-EXECUTE-API-ON-SERVER * : must be set to true ON EACH CALL. * : In this case, you may not use * : API-PRINTDIALOG to obtain the printer * : name as it will pop up the dialog box * : in the wrong place. Use our * : API-GETPRINTERS instead. * : * : In all cases, it may be more user * : friendly to record the users printer * : choice in the registry for each type * : of document rather than asking each * : time for them to choose a printer. * : See FUNC-REGISTRY-PUT / GET * : * To use: * * COPY WIN32API. * COPY PRINTAPI. * COPY GSPRTDEF. * * --- --- Typical calls - one of each type --- --- * * * : (First fetch printer name with * : API-PRINTDIALOG, or set * : PRINTAPI-DIALOG-HWND to your * : panel's Hwnd, and set printe name to * : low-values. * SET PRINTAPI-OPENPRINTER-DEFAULTS TO TRUE * MOVE PRTDLG-PRINTER-NAME TO PRINTAPI-OPENPRINTER-NAME * SET API-OPENPRINTER TO TRUE * CALL 'GSWINAPI' USING WIN32API-PARMS * PRINTAPI-HANDLE * PRINTAPI-OPENPRINTER-DATA * GS-DEVMODE-DATA * WIN32API-D * WIN32API-E * WIN32API-F. * * * MOVE 'My GUI ScreenIO Report' TO PRINTAPI-STARTDOC-NAME * SET PRINTAPI-DATA-RAW TO TRUE * SET API-STARTDOCPRINTER TO TRUE * CALL 'GSWINAPI' USING WIN32API-PARMS * PRINTAPI-HANDLE * PRINTAPI-STARTDOC-DATA * WIN32API-C * WIN32API-D * WIN32API-E * WIN32API-F. * * * SET API-STARTPAGEPRINTER TO TRUE * CALL 'GSWINAPI' USING WIN32API-PARMS * PRINTAPI-HANDLE * WIN32API-B * WIN32API-C * WIN32API-D * WIN32API-E * WIN32API-F. * * * MOVE LENGTH OF MY-DATA-BUFFER TO PRINTAPI-WRITEPRINTER-SIZE * MOVE ZERO TO PRINTAPI-WRITEPRINTER-WRITTEN * SET API-WRITEPRINTER TO TRUE * CALL 'GSWINAPI' USING WIN32API-PARMS * PRINTAPI-HANDLE * PRINTAPI-WRITEPRINTER-DATA * : Warning: for Client/Server deployments * : keep your buffer less than 32k * MY-DATA-BUFFER * WIN32API-D * WIN32API-E * WIN32API-F. * * * SET API-ENDPAGEPRINTER TO TRUE * CALL 'GSWINAPI' USING WIN32API-PARMS * PRINTAPI-HANDLE * WIN32API-B * WIN32API-C * WIN32API-D * WIN32API-E * WIN32API-F. * * (repeat above three calls as necessary) * * * SET API-ENDDOCPRINTER TO TRUE * CALL 'GSWINAPI' USING WIN32API-PARMS * PRINTAPI-HANDLE * WIN32API-B * WIN32API-C * WIN32API-D * WIN32API-E * WIN32API-F. * * * SET API-CLOSEPRINTER TO TRUE * CALL 'GSWINAPI' USING WIN32API-PARMS * PRINTAPI-HANDLE * WIN32API-B * WIN32API-C * WIN32API-D * WIN32API-E * WIN32API-F. * * * After each call, you may want to check status.... * * IF WIN32API-FAILED * do print-not-possible-or-canceled * ELSE * continue printing report * * ---------------------------------------------------------------- * : FOR ALL PRINTAPIs (first arg) * : Handle to the printer. Output of * : OpenPrinter, input to all others. 01 PRINTAPI-HANDLE PIC X(4) VALUE LOW-VALUES. * : FOR OPENPRINTER Two args. * : Name of the printer, either from * : API-GETPRINTERS or API-PRINTDIALOG. * : If you leave low-values and move panel * : hwnd to PRINTAPI-DIALOG-HWND the * : PrintDialog API will be launched * : automatically for you and printer name * : returned, and hwnd cleared so * : subsequent prints with this same data * : buffer will default to same printer. * : (not valid when forcing server side.) 01 PRINTAPI-OPENPRINTER-DATA VALUE LOW-VALUES. 05 PRINTAPI-OPENPRINTER-NAME PIC X(100). 05 PRINTAPI-DIALOG-HWND PIC X(4). * : FOR STARTDOCPRINTER Two Args 01 PRINTAPI-STARTDOC-DATA VALUE LOW-VALUES. * : This is the spoolers print job name * : any value will do. 05 PRINTAPI-STARTDOC-NAME PIC X(50). * : Specify the type of data you will be * : sending. Use Raw for printing data * : that is pre-formatted and contains * : contains all necessary printer driver * : commands (HPCL, Postscript,etc). * : See Settings in CtrlPanel Printers. 05 PRINTAPI-STARTDOC-DATA-TYPE PIC X(10). 88 PRINTAPI-DATA-RAW VALUE 'RAW'. 88 PRINTAPI-DATA-EMF VALUE 'EMF'. * : FOR WRITEPRINTER Three args * : Third arg is your data buffer. 01 PRINTAPI-WRITEPRINTER-DATA VALUE LOW-VALUES. * : Input - size of data you are sending 05 PRINTAPI-WRITEPRINTER-SIZE PIC 9(9) COMP-5. * : bytes sent to printer 05 PRINTAPI-WRITEPRINTER-WRITTEN PIC 9(9) COMP-5.