1. Vipin Dwivedi
  2. PowerBuilder
  3. Wednesday, 19 May 2021 16:04 PM UTC

Hello Appeon Team,

I have one observation and need your help.

In our Application we have one Menu in our application, File ->Page Setup. Here I am calling PrintSetup() Powerscript function, which open the dialog box with list of all available printer. Our applications are running on Microsoft 2016 server.

As per PrintSetup() documentation, it let you switch your printer during your application session without affecting your default printer. Once you re-run the application, it will again show you system default printer has highlighted and let you choose printer for your application session.

My question is -

  • When I select the printer and hit OK, does it store in application memory or in registry?


  • In 2016 server, I see some odd behavior which is, when dialog box opens, select any printer and hit OK and re-open the dialog box next time, it does not highlight my last selected printer. Sometime it does not show any printer highlighted though I have my own client default printer set in Print Management or Device and Printer setting.


Please advice.



Vipin Dwivedi Accepted Answer Pending Moderation
  1. Wednesday, 19 May 2021 19:52 PM UTC
  2. PowerBuilder
  3. # 1

I don't know why I get no printer selected when call PrintSetup(). Let me give you the scenario where it fails when I don't see any printer highlighted in PrintSetup().

We have system configuration maintenance program where we set the printer by the PSR file (Each PSR file belongs to some process like part_invoice.psr file will belong to part sales order, workshop_invoice.psr for workshop invoice etc.

For few programs, we set the printer as default printer i.e <default> or <windefault>

For few programs we set the printer as <Selectable> means it will open printer select dialog box when give print command.

We store these configuration setting into config table.

Our programs have facility to print and archive the document (We have check box for those options). For archive, we have Amyuni PDF driver which print/save as file into PDF. Here are the steps we follow during Print and Archive.


String lb_printdlg = TRUE // Always display print dialog

1 Look into Configuration table and look what is the printer option

2  If <Selectable> Then 

           Set Dw_Obj.Modify("Datawindow.Printer=''");

            lb_printdlg = TRUE //Open dialog box.

   ElseIf <default> Then

          lb_printdlg = FALSE //Don't open dialog box.


        Call Windows Printer from Registry based on OS Type

             Case Windows

                      RegistryGet('HKEY_LOCAL_MACHINE\Config\0001\System\CurrentControlSet\Control\Print\Printers',                        'default', ls_winprinter)

                    Case WindowsNT

                        RegistryGet('HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows',                                  'Device', ls_winprinter)

           Call ls_currentPrinter = PrintGetPrinter()

           If ls_currentPrinter <> ls_winprinter //Windowsdefault printer is not same as PrintGetPrinter()


                   PrintSetPrinter(ls_WinPrinter) //Set Windows Default Printer as printer.....

                   lb_printdlg = FALSE//Don't Open dialog box.

3. Dw_Obj.Print(True, lb_printdlg ) //lb_printdlg will determine whether to open the dialogbox or not.

4. PrintSetPrinter(ls_currentprinter) //Restore the printer changed in <WinDefault> condition...


For Archive

ls_printer = PrintGetPrinter() //Store current printer

PrintSetPrinter("Amyuni Printer")

Dw_Obj.saveAs(); // Overwrite SaveAs() and call Amyuni API.

PrintSetPrinter(ls_printer) //Restore printer...... Here we have issue as ls_printer is coming as blank when we don't see any printer highlighted in PrintSetup() dialog box.


Kindly advice.



  1. Mark Lee @Appeon
  2. Monday, 24 May 2021 10:16 AM UTC
Hi Vipin,

Does the issue exist in PB 2017 R3 1858? As I replied to you in ticket 6261, have you tried to test your application in PB 2019 R3 2703? We need you to confirm whether it is also resolved in PB 2019 R3 because we can’t reproduce it on our side.

For this issue, have you checked whether the return value of the PrintSetPrinter function is 1? Due to that we can’t duplicate it locally, could you please try to add Yield() before the PrintSetPrinter method and see if there are any differences.

BTW, if you could provide a reproducible sample test case (including PBT/PBL) to us, please submit a ticket to our ticket system https://www.appeon.com/standardsupport/newbug with this test case so it can be properly received and tracked. Thanks in advance.

  1. Helpful
  1. Vipin Dwivedi
  2. Wednesday, 2 June 2021 21:45 PM UTC
I haven't tried in PB2019 R3 2703 version yet.
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 19 May 2021 17:58 PM UTC
  2. PowerBuilder
  3. # 2

Hi Vipin, This is perhaps a bit off topic, but have you considered getting rid of remote desktop and instead deploying as a real cloud app with PowerServer 2021?  Remote desktop is a workaround... running as real cloud app won't have config issues and other remote desktop limitations. 

  1. Vipin Dwivedi
  2. Wednesday, 19 May 2021 18:06 PM UTC
That may be our future plan but right now we are in 2017R3 version and we are going to use this version for some time.

Just to let you know our company is moving dedicated physical servers to AWS cloud server (VM machine) and installing the application over cloud but in this process also nothing is changing except the machine (Physical to cloud).

  1. Helpful
  1. Armeen Mazda @Appeon
  2. Thursday, 20 May 2021 04:27 AM UTC
I don't think it is guaranteed VM and physical machine are exactly the same, at least when it comes to things involving hardware like printer configs. I don't know the answer to your issue otherwise I would help you.
  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.