1. Ankit Gupta
  2. PowerBuilder
  3. Monday, 19 July 2021 18:01 PM UTC

PB2019 - Issue in Print when the System set to a default printer

Steps to Replicate :
1. Set a Default printer (Any local printer to the system ) Choosed XPS document printer in this case
2. Launch the application
3. Navigate to Reports 
4. Generate the report 
5. Select print from the tool bar
6. On the Printing options window change the default Printer to Primo PDF /Print to PDF and Hit OK
7. The application still points to default printer(XPS document printer) and prints

This issue does not happen with PB 2019 IDE but only with the build.

Let me know if there is an upgraded DLL to address this issue or any other solution will be appreciated.


Ankit Gupta


Olan Knight Accepted Answer Pending Moderation
  1. Friday, 6 August 2021 19:51 PM UTC
  2. PowerBuilder
  3. # 1

Tracy -

   This is PBv12.1 code that I have that works in every environment we have except one. In that ONE VM, the call to PrintGetPrinter() causes the app to abend.

// In the OPEN event
STRING                            &
    ls_printer_detail_array,    &
    ls_printer_detail_printer_name, ls_ver, ls_title
ls_printer_detail_array = PrintGetPrinter()

ll_position = PosA(ls_printer_detail_array,"~t")
ls_printer_detail_printer_name = LeftA(ls_printer_detail_array,ll_position - 1)

// this is a text field on the window that displays the current printer
sle_printer.Text = 'Printer = '+ls_printer_detail_printer_name

// cb_change_printer
// This is a command button on the window

// Clicked event

// w_set_default_printer
// File is attached. Rename w_set_default_printer.jpg to w_set_default_printer.srw.


To manually update the Registry with the current printer:

        "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows"




Good Luck,


Attachments (1)
  1. Tracy Lamb
  2. Friday, 13 August 2021 15:02 PM UTC
Thank you for providing this info! Dissecting it now to see how to implement it (or something like it) in my application.


  1. Helpful
  1. Olan Knight
  2. Friday, 13 August 2021 16:03 PM UTC
You are welcome! :)
  1. Helpful
There are no comments made yet.
Tracy Lamb Accepted Answer Pending Moderation
  1. Thursday, 5 August 2021 17:40 PM UTC
  2. PowerBuilder
  3. # 2

I'm having the same problem... my users select Print Setup and change the default printer.  But that change isn't changing the default printer in windows. File -> Print is ignoring what was set in Printer Setup, but PrintImmediate toolbar button is remembering it, meanwhile the Windows default printer isn't changing.

I don't know when Print, PrintSetup and PrintImmediate changed, but this code has worked for 20+ years with my applications, until I migrated to PB12 and Windows 10.



There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 19 July 2021 21:34 PM UTC
  2. PowerBuilder
  3. # 3

HI Ankit;

  Please try using the PrintSetPrinter() command in your PB App to change the current default printer for your App EXE.


Regards ... Chris

There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 19 July 2021 20:07 PM UTC
  2. PowerBuilder
  3. # 4

I think this is the standard behavior. The default printer will not change when you change the printer in the PRINTING module. To change the default printer requires that it be changed in the application itself.

At least, that's what I have seen. Depending on your version of Windows, sometimes the previously selected printer will be the new default in the PRINTING options.

Later -



  1. Tracy Lamb
  2. Thursday, 5 August 2021 18:12 PM UTC
When the user selects a printer, how do I change that printer to the new default in windows?


  1. Helpful
There are no comments made yet.
  • Page :
  • 1

There are no replies made for this question yet.
However, you are not allowed to reply to this question.