1. Luca Militello
  2. PowerBuilder
  3. Tuesday, 9 June 2020 09:35 AM UTC

Hi,

a problem occurred while migrating application to PB2017 R3 Build 1915 from PB12_5.

This is the scenario:

the application needs to set a specific printer before printing document. There could be many documents printing and everyone could have a different printer.

This operation is made by setting windows registry using the function  RegistrySet(as_key, as_value, as_var) before printing the document

where

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

as_value = 'Device'

as_var = <printer name>

In PB12_5 and lower versions the application give no problem, even in Win10, but only in runtime. 

In PB2017 or PB2019 (i download the trial of PB2019 to try with this version) it uses always the default printer even if it correctly set the 'Device' key  with the right printer. Morover and apparently randomly, sometimes the application seems to work  but the document not printed. This never happen with PB12_5 version.

From PB environment (Pb12_5, Pb2017 and PB2019) the 'Device' key is correctly set, but no way to print with specific printer (always uses default printer).

Someone could help me?

Thanks a lot

Luca

 

David Peace (Powersoft) Accepted Answer Pending Moderation
  1. Tuesday, 9 June 2020 10:26 AM UTC
  2. PowerBuilder
  3. # 1

Hi Luca

I wonder if this is getting in the the way:

https://www.printandshare.info/kb/articles/00003/how-to-set-the-default-printer-in-windows-10-back

It's specifically Windows 10, but we have has issues with this and needed to turn it off.

I'm not convinced that it's a PB problem more and OS problem.

Regards

David

Comment
  1. Luca Militello
  2. Tuesday, 9 June 2020 13:01 PM UTC
Hi David,

thank you for your answer.

I checked the parameter included in the article you suggested, but nothing changed.



I think it's a problem with PB version (PB2017 , PB2019) and not of the OS, because with previous version (PB12_5) everything was ok with runtime application, so probably something was changed between the print request that PB send to the OS.

The same problem (with PB2017 compilation) happens with Win7.



Thank you



Luca
  1. Helpful
There are no comments made yet.
Brad Mettee Accepted Answer Pending Moderation
  1. Tuesday, 9 June 2020 13:26 PM UTC
  2. PowerBuilder
  3. # 2

Why not set the printer through the datawindow directly?

dwc_1.object.datawindow.printer = "<printer name here>"

Get the list of printers with PrintGetPrinters(), match the beginning of the name (up to the first comma), and use that string.

Query the property to see the correct format for the string to use.

 

Comment
  1. Luca Militello
  2. Tuesday, 9 June 2020 13:48 PM UTC
Hi Brad,

thank you.

The printer setting using the registry is made before creating the DW that will be printed. This information is not available when the DW is populated. I have to modify some procedures to do that.

If this is a bug then i will be forced to modify the application.



Thanks a lot



Luca



  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 9 June 2020 13:39 PM UTC
  2. PowerBuilder
  3. # 3

Greetings, Luca - 

I agree with Brad. Try using the PrintGetPrinter, PrintGetPrinters, PrintSetPrinter PowerScript functions instead of trying to manipulate the Windows Registry.

Let's say, for argument's sake, that Appeon inadvertently introduced a bug in PB 2017. If there is an alternative technique that accomplishes what you want, wouldn't you want to make the necessary code changes and move forward, or do you want to wait for what could be potentially several months for a bug fix?

Regards, John

Comment
  1. Luca Militello
  2. Tuesday, 9 June 2020 13:52 PM UTC
Hi John,

i agree with you.

At the moment I just wanted to make sure it was a bug and that there is something I'm wrong about instead.



Thank you

Luca
  1. Helpful
There are no comments made yet.
Mark Lee @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 10 June 2020 09:52 AM UTC
  2. PowerBuilder
  3. # 4

Hi Luca,

I wrote a small case according to your description and found that PB 11.5, PB 12.5, PB 12.6, and PB 2019 all have the same issue. 

When the app is launched, the default printer value will be gained and kept in your app, after you use the RegistrySet method to change the Windows default printer, the original default printer value won't be change in your app. You can use the printsetPrinter method to set the default printer again to work it around. 

Correct me if my understanding is wrong, if you don't think we are on the same page, please report this problem to our ticket system: https://www.appeon.com/standardsupport/newbug so it can be properly received and tracked.

And also please provide a reproducible sample PB test case (with PBT / PBL) to us for more study when submitting the ticket, thanks in advance.

Regards,

 

Comment
  1. Luca Militello
  2. Wednesday, 10 June 2020 10:39 AM UTC
Hi Mark,

thank you for your reply.



I agree with you but i have to report a slightly different behavior in my app from what you say.

We have to distinguish this cases:



- launching the app from environment (PB 12_5, Pb2017, PB2019 ) RegistrySet method works fine setting the right printer but after that it always uses the default printer to print document . Behavior is the same for Win10, Win7



- launching the .exe file after deploy, only with PB12_5 compilation it works fine. This is certainly true because we have several users that are now using the app (deployed in PB12_5 and on different OS , Win10 included) without any problem. We noticed the bug beacuse we are porting the app from PB12_5 to PB2017 (or PB2019) to get official certification of compatibility for Win10.



If it' necessary i will provide a test case



Thank you very much

Best regards

Luca



  1. Helpful
  1. Mark Lee @Appeon
  2. Thursday, 11 June 2020 02:12 AM UTC
Hi Luca,

Yes, please report this problem to our ticket system: https://www.appeon.com/standardsupport/newbug and also upload the test case when submitting the ticket, thanks in advance.
  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.