プリンターが開く前に、プロセス全体のデフォルトプリンターを設定する。
call "PC_PRINTER_SET_DEFAULT" using by value default-option by reference default-struct returning status-code
呼び出しプロトタイプ使用時 ( 説明の読み方) | PIC (32 ビット システム) | ||||
---|---|---|---|---|---|
default-option | cblt-x4-comp5 | pic x(4) comp-5. | |||
default-option が1に設定されている場合 | |||||
default-struct | 以下を含むcblte-pd-printer-nameとして事前定義された集団: | 以下を含む集団項目: | |||
cblte-pd-printer-name-len | cblt-x2-comp5 | pic x(2) comp-5. | |||
cblte-pd-printer-name | pic x(cblte-pd-printer-name-len). | pic x(printer-name-length). | |||
default-optionが2に設定されている場合 | |||||
default-struct | 以下を含むcblte-pd-printer-browseとして事前定義された集団: | 以下を含む集団項目: | |||
cblte-pd-printer-browse-hwnd | cblt-x4-comp5 | pic x(4) comp-5. | |||
cblte-pd-printer-browse-namelen | cblt-x2-comp5 | pic x(2) comp-5. | |||
cblte-pd-reserved | cblt-x2-comp5 | pic x(2) comp-5. | |||
cblte-pd-printer-browse-name | pic x(cblte-pd-printer-browse-namelen). | pic x(printer-name-length). | |||
status-code | 説明の読み方参照 |
default-option | default-optionを指定する。
|
||||
default-optionが1に設定されている場合: | |||||
printer-name-length | printer-nameの長さ | ||||
printer-name | プリンターの名称 | ||||
default-optionが2に設定されている場合: | |||||
browser-hwnd | プリンターブラウザのハンドル |
default-optionが2に設定されている場合:
printer-name-length | printer-nameの長さ |
printer-name | プリンターの名称 |
reserved | 確保 |
status-code | ステータスコード |
default-option2を設定した場合、本関数はユーザーが選択したプリンターへ返すが、デフォルトプリンターとしての設定はしない。
WindowsNTでは、プリンター名はUNCフォーマットにて入力されなければならない(すなわち、ネットワークで表示されるデバイスのフル ネーム)。
例1:
以下の例では、デフォルトプリンターの設定におけるPC_PRINTER_SET_DEFAULTの使用方法を示す。
working-storage section. 01 MyDocumentInfo. 03 filename. 05 len pic x(2) comp-5. 05 body pic x(128). 03 document. 05 len pic x(2) comp-5. 05 body pic x(128). 03 document-flags pic x(4) comp-5. 03 window-hwnd pic x(4) comp-5. 01 Printer-RetCode pic 9(4) comp-5. 78 USE-OPEN-DIALOG value 1. 78 USE-FONT-DIALOG value 2. 78 USE-FORCE-PORTRAIT value 4. 78 USE-FORCE-LANDSCAPE value 8. 78 USE-PROGRESS-DIALOG value 16. 01 default-info. 03 option pic x(4) comp-5. 03 ourprinter. 05 len pic x(2) comp-5. 05 body pic x(128). 78 SET-DEFAULT-PRINTER value h"0001". procedure division. move "My Color PS" to body of ourprinter of default-info move 11 to len of ourprinter of default-info move SET-DEFAULT-PRINTER to option of default-info call "PC_PRINTER_SET_DEFAULT" using by value option of default-info, by reference ourprinter of default-info returning Printer-RetCode end-call if Printer-RetCode not equal zero display "Unable to setup a default printer" display " + Retcode = " Printer-RetCode stop run end-if move "c:\config.sys" to body of filename move 13 to len of filename move "My Config.sys" to body of document move 13 to len of document move USE-PROGRESS-DIALOG to document-flags move zero to window-hwnd call "PC_PRINT_FILE" using by reference filename by reference document by value document-flags by value window-hwnd returning Printer-RetCode end-call if Printer-RetCode not equal zero display "PC_PRINT_FILE failed.. " Printer-RetCode else display "PC_PRINT_FILE: OK" end-if .
例2:
以下の例では、プリンターを閲覧するためのPC_PRINTER_SET_DEFAULTの使用方法を示す。この例はWindowsNTのみに対応している。
working-storage section. 01 MyDocumentInfo. 03 filename. 05 len pic x(2) comp-5. 05 body pic x(128). 03 document. 05 len pic x(2) comp-5. 05 body pic x(128). 03 document-flags pic x(4) comp-5. 03 window-handle pic x(4) comp-5. 01 MyDefaultPrinter. 03 hwnd pic x(4) comp-5. 03 len pic x(2) comp-5. 03 reserved pic x(2) comp-5. 03 body pic x(128). 01 Printer-RetCode pic 9(4) comp-5. 78 USE-OPEN-DIALOG value 1. 78 USE-FONT-DIALOG value 2. 78 USE-FORCE-PORTRAIT value 4. 78 USE-FORCE-LANDSCAPE value 8. 78 USE-PROGRESS-DIALOG value 16. 01 default-info. 03 option pic x(4) comp-5. 03 ourprinter. 05 len pic x(2) comp-5. 05 body pic x(128). 78 SET-DEFAULT-PRINTER value h"0001". 78 BROWSE-DEFAULT-PRINTER value h"0002". linkage section. 01 lnk-hwnd pic x(4) comp-5. procedure division using by value lnk-hwnd. move BROWSE-DEFAULT-PRINTER to option of default-info move lnk-hwnd to hwnd of MyDefaultPrinter move 127 to len of MyDefaultPrinter call "PC_PRINTER_SET_DEFAULT" using by value option of default-info by reference hwnd returning Printer-RetCode end-call if Printer-RetCode not equal zero display "Unable to browse for a default printer" display " + Retcode = " Printer-RetCode stop run end-if display "Browse Printer : " body of MyDefaultPrinter(1:len of MyDefaultPrinter) move SET-DEFAULT-PRINTER to option of default-info move len of MyDefaultPrinter to len of ourprinter move body of MyDefaultPrinter(1:len of MyDefaultPrinter) to body of ourprinter call "PC_PRINTER_SET_DEFAULT" using by value option of default-info by reference ourprinter of default-info returning Printer-RetCode end-call if Printer-RetCode not equal zero display "Unable to set a default printer" display " + Retcode = " Printer-RetCode stop run end-if move "c:\config.sys" to body of filename move 13 to len of filename move "My Config.sys" to body of document move 13 to len of document move USE-PROGRESS-DIALOG to document-flags move zero to window-handle call "PC_PRINT_FILE" using by reference filename by reference document by value document-flags by value window-handle returning Printer-RetCode end-call if Printer-RetCode not equal zero display "PC_PRINT_FILE failed.. " Printer-RetCode else display "PC_PRINT_FILE: OK" end-if .