1. Tor-Egil Nygaard
  2. PowerBuilder
  3. Monday, 26 March 2018 08:12 AM UTC

Problem :
Opening a window with the new RTE control is very slow when the application is run on a terminal server with printer redirection enabled, and the "default" printer is set to use the "Remote Desktop Easy print" printer driver. This happens when the client printer driver is not installed on the terminal server. If default printer is changed to a printer which is installed on the terminal server the window opens instantly.

Workaround :

It is possible to get around this problem, but it requires some work to be done and the use of windows api functions. We have used OpenPrinter, GetPrinter and SetDefaultPrinter.

First you will have to delete the RTE control on the window/tab-page. Make a note off its location ( X and Y ) and size ( width and height ).

In the preopen or open event of the window you will have to check if the default printer driver is windows "REMOTE DESKTOP EASY PRINT". If it is, take a note of the name of the printer, and then you will have to change it to a printer which is not using this driver ( i.e. the “Microsoft XPS Document Writer” ).

Now you create the RTE control, set its properties and open/create it using OpenUserObjectWithParm.

RichTextEdit     rte_control

rte_control = Create RichTextEdit

rte_control.x = 14

rte_control.y = 680

rte_control.width = 3771

rte_control.height = 980

OpenUserObjectWithParm (rte_control, "", 14, 680 )

rte_control.BringToTop = True

Now you change the default printer back to what it was originally.

It is not an ideal solution to the problem but it does make the window open much faster.

 

TEN

Tor-Egil Nygaard Accepted Answer Pending Moderation
  1. Tuesday, 3 April 2018 07:14 AM UTC
  2. PowerBuilder
  3. # 1

Hi,

Here is the declaration of the windows api-functions you asked for

Function ulong OpenPrinter (string pPrinterName, ref ulong phPrinter, ref str_printer_defaults pDefault) LIBRARY "winspool.drv" ALIAS FOR "OpenPrinterW"
Function long OpenPrinter ( string pPrinterName, ref ulong phPrinter, long pDefault ) Library "winspool.drv" Alias For "OpenPrinterW"
Function ulong ClosePrinter ( ulong hPrinter ) LIBRARY "winspool.drv"

Function long GetPrinter (ulong hPrinter, long Level, long buffer, long pbSize, ref long pbSizeNeeded ) Library "winspool.drv" Alias For"GetPrinterW"
Function long GetPrinter (ulong hPrinter, long Level, ref blob buffer, long pbSize, ref long pbSizeNeeded ) Library "winspool.drv" Alias For"GetPrinterW"

Function Boolean SetDefaultPrinter( Ref String pszPrinter ) Library "winspool.drv" Alias for "SetDefaultPrinterW"

 

TEN

Comment
There are no comments made yet.
Ravi Nath Accepted Answer Pending Moderation
  1. Friday, 30 March 2018 16:34 PM UTC
  2. PowerBuilder
  3. # 2

Hi,

Can you please share the local declaration of these functions in your script:

OpenPrinter, GetPrinter and SetDefaultPrinter

 

I am having the same issue and will like to try your solution.

 

Thanks,

 

Ravi

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 28 March 2018 06:15 AM UTC
  2. PowerBuilder
  3. # 3

Great tip! Thanks.

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 27 March 2018 14:40 PM UTC
  2. PowerBuilder
  3. # 4

Nice! Thanks for sharing this tip!

Olan

Comment
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.