Highlighted
Absent Member.
Absent Member.
1605 views

Printer Browser

Jump to solution

I was looking at the examples in "PC_PRINTER_SET_DEFAULT". Example #2 uses the routine to brows for a printer. It then uses the routine to set the printer as the default. It then uses "PC_PRINT_FILE" to print a file to the printer. This is just what I need. The problem is that the example and the routine definition do not explain where the "Printer Browser Handle" comes from. The example uses a linkage section variable. Could you let me know where this handle comes from and how to use it? What I want to do is to let the user select a printer and then print two files to this printer. Concatenating the two files before printing is NOT an option. 

Jerry

1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Printer Browser

Jump to solution

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.
           

View solution in original post

0 Likes
2 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Printer Browser

Jump to solution

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.
           

View solution in original post

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

RE: Printer Browser

Jump to solution

Hi Jerry. Apologies for the problems caused by the documentation for this routine not being as clear as it could be. We will look to provide some clearer descriptions for the parameters for these calls.

Thanks

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.