Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: Printer Browser

$
0
0

Hi Jerry,

Sorry, the example is misleading.

The browser handle is actually referring to the window handle that you would like to be the parent of the print selection dialog.

You can set this to 0 is you want the current window to be the parent.

I did a test here using the example in the docs and although it works fine from a native code project it does not appear to be working correctly from a managed code project.

I will create an rpi for this.

As a workaround in a managed code project you can use the PrintDialog class to get the printer name and use it instead of the browse function.

Example:

          declare myprintdialog as type PrintDialog = new PrintDialog
          if myprintdialog::ShowDialog = type DialogResult::OK
             move myprintDialog::PrinterSettings::PrinterName to body of ourprinter
             move myprintDialog::PrinterSettings::PrinterName::Length to len of ourprinter
          end-if
       
           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 set a default printer"
              display " + Retcode = " Printer-RetCode
              stop run
           end-if

           move "c:\temp\mytest.txt" to body of filename
           move 18 to len of filename
 
           move "My test" to body of document
           move 7 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
           goback.
           

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>