_osprint query

Hi,

Just a general query about _osprint.
We have a legacy system running 9.1E CHUI under windows (xp and 98) and the user wants to utilise the windows printing options – so we thought we could use _osprint etc.
However we cannot change the font so any landscape reports are truncated – not what I’d hoped for.
On looking on the Progress knowledgebase (P40596) there says that there is no workround.
Has anybody managed to ‘fiddle/fudge’ this so that it will work, or do I just accept it?
Regards
Mike
 
Not much help, sorry.

What the KB entry doesn't say is that the actual work is undertaken via a progress dll, proprint, which is possibly why a 4GL workaround is not available.

If no one has an answer, the only route I can think of (apart from using an alternative reporting solution), is to write your own wrapper for the Windows print set up interface, but that may be more trouble than its worth and possibly the reason Progress have supplied their own interface.
 
Or, send your file to the printer using a seperate (Windows) _osprint/whatever session.

It's quite normal to have seperate sessions (normally on the server) handling print jobs.

I'm assuming here it is possible to have Window sessions launched by Character sessions on the same machine, but this may be incorrect - I don't use CHUI.
 
We tried using _osprint and had the same problems. In the end, we used printfile.p from Jurgen's website which, if you add more input parameters works a treat.
 
Thanks

I will look into the use of printfile.p and it works OK - sending it to LPT1.
BUT (always a But?) how do I get the windows Print Dialog Box so that the user can choose any printer on the network to send it to.

Mike
 
You can use the system-dialog printer-setup command to select a printer, then capture this using session:printer-port and pass this value into printfile.p using the p-Devicename input parameter. If you don't have p-devicename as an input parameter then change the program as it makes it much easier to control.

def var this_printer as char no-undo.
SYSTEM-DIALOG PRINTER-SETUP.
this_printer = session:printer-port.
message this_printer view-as alert-box.


 
What we tend to do is to store printers in a Progress Table. Users choose a printer from the table and we use the corresponding devicepath in printfile.p.

Alternatively, you could try to extract the Windows printers into a temp-table and browse that to select a printer.

We use prntlist.p to extract system printer information, then save it to a temporary file. We then import it in the calling program and use a combo-box to choose a printer, then pass the appropriate values to printfile.p.



/*
Program: prntlist.p
Purpose: Get information on printers set up in Windows Print Settings
Author: Simon Phipp - based on code by f_lugs@hotmail.com
Date: 29 May 2002
*/
/* Define the widget handle for the window */

define input param output_file as char no-undo.

define temp-table t_printer
field ipname as char
field ipaddress as char
field printername as character form "x(20)"
field printerport as character form "x(20)"
field printerhandle as char
field printerhprinter as int
field printerstatus as int
field printerdriver as char form "x(20)".

def var this_ip_address as char no-undo.
def var this_ip_name as char no-undo.
run system\ipname.p (output this_ip_name, output this_ip_address).
run p_get_info.
run p_show_printers.
/* ********************** Procedures *********************** */

PROCEDURE EnumPrintersA EXTERNAL "winspool.drv":
DEFINE RETURN PARAMETER res AS LONG.
DEFINE INPUT PARAMETER flags AS LONG.
DEFINE INPUT PARAMETER name AS CHARACTER.
DEFINE INPUT PARAMETER Level AS LONG.
DEFINE INPUT-OUTPUT PARAMETER pPrinterEnum AS MEMPTR.
DEFINE INPUT PARAMETER cdBuf AS LONG.
DEFINE OUTPUT PARAMETER pcbNeeded AS LONG.
DEFINE OUTPUT PARAMETER pcReturned AS LONG.
END PROCEDURE.
PROCEDURE OpenPrinterA EXTERNAL "winspool.drv":
DEFINE INPUT PARAMETER pPrinterName AS CHAR.
DEFINE OUTPUT PARAMETER phPrinter AS LONG.
DEFINE INPUT PARAMETER pDefault AS CHAR.
define return parameter i-sts as long.
END.
PROCEDURE ClosePrinter EXTERNAL "winspool.drv":
DEFINE INPUT PARAMETER phPrinter AS LONG.
END.
PROCEDURE GetPrinterDriverA EXTERNAL "winspool.drv":
DEFINE INPUT PARAMETER hPrinter AS LONG. /* printer object */
DEFINE INPUT PARAMETER lpszEnv AS CHAR. /* address of environment */
DEFINE INPUT PARAMETER dwLevel AS LONG. /* structure level */
DEFINE INPUT-OUTPUT PARAMETER lpbDrvInfo AS MEMPTR. /* address of structure array */
DEFINE INPUT PARAMETER cbBuf AS LONG. /* size, in bytes, of array */
DEFINE OUTPUT PARAMETER lpdwNeeded AS LONG. /* addr. of variable with count of bytes */
END.

PROCEDURE deletePrinterList :
/*------------------------------------------------------------------
Purpose: Delete the printer list items Parameters: <none>
Notes:
--------------------------------------------------------------------*/
for each t_printer:
delete t_printer.
end.
END PROCEDURE.


procedure p_get_info:
define variable pPrinterInfo as memptr no-undo.
define variable lpPrinterName as memptr no-undo.
define variable lpDriver as memptr no-undo.
define variable pPrinterEnum as memptr no-undo.
define variable pDriverInfo as memptr no-undo.
define variable pDriver as memptr no-undo.
define variable i as integer no-undo.
define variable i-sts as integer no-undo.
define variable res as integer no-undo.
define variable pcbNeedDrv as integer no-undo.
define variable pcbNeeded as integer no-undo.
define variable pcReturned as integer no-undo.


def var hprinter as int no-undo.
def var this_port as char no-undo.
/* initial value */
/* Just want to know the correct size of the pPrinterEnum MEMPTR */
set-size(pPrinterEnum)= 1208.
/* Delete the printer list */
run deletePrinterList .
run EnumPrintersA(
output res,
input 2,
input "",
input 2,
input-output pPrinterEnum,
input get-size(pPrinterEnum),
OUTPUT pcbNeeded,
OUTPUT pcReturned). /* Number of printers */
/* Get the size of the pPrinterEnum MEMPTR */
SET-SIZE(pPrinterEnum)= 0.
SET-SIZE(pPrinterEnum)= pcbNeeded.
run EnumPrintersA(
output res,
input 2,
input "",
input 2,
input-output pPrinterEnum,
input get-size(pPrinterEnum),
OUTPUT pcbNeeded,
OUTPUT pcReturned). /* Number of printers */
/* Printer list */
DO i = 0 TO pcReturned - 1 :
SET-POINTER-VALUE(pPrinterInfo) = GET-POINTER-VALUE(pPrinterEnum) + (i * 84 ).
/* Port */
SET-POINTER-VALUE(lpPrinterName) = GET-LONG(pPrinterInfo,13).
this_port = GET-STRING(lpPrinterName,1).
/* Printer Name */
SET-POINTER-VALUE(lpPrinterName) = GET-LONG(pPrinterInfo,5).
find first t_printer where t_printer.printername = STRING(GET-STRING(lpPrinterName,1)) no-error.

if not available t_printer then do:
create t_printer.
assign
t_printer.printername = STRING(GET-STRING(lpPrinterName,1))
t_printer.ipname = this_ip_name
t_printer.ipaddress = this_ip_address.
end.
t_printer.printerport = this_port.
/* Opens the printer */
run OpenPrinterA( INPUT STRING(GET-STRING(lpPrinterName,1)),
OUTPUT hprinter,
INPUT "",
OUTPUT i-sts ).
t_printer.printerhandle = GET-STRING(lpPrinterName,1).
t_printer.printerhprinter = hprinter.
t_printer.printerstatus = i-sts.
if hprinter = 0 then next.
/* initial value */
/* Just want to know the correct size of the pDriverInfo MEMPTR */ set-size(pDriverInfo)= 1208.
/* Tenta achar o driver */
run GetPrinterDriverA (
hprinter,
"",
2,
input-output pDriverInfo,
input get-size(pDriverInfo),
output pcbNeedDrv ).
/* Get the size of the pPrinterEnum MEMPTR */
SET-SIZE(pDriverInfo)= 0.
SET-SIZE(pDriverInfo)= pcbNeedDrv.
/* Try to find the printer driver */ run GetPrinterDriverA ( hprinter,
"",
2,
input-output pDriverInfo,
input get-size(pDriverInfo),
output pcbNeedDrv ).
SET-POINTER-VALUE(pDriver) = GET-POINTER-VALUE(pDriverInfo) + (i * 84 ).
/* Driver */
SET-POINTER-VALUE(lpDriver) = GET-LONG(pDriverInfo,13).
t_printer.printerdriver = GET-STRING(lpDriver,1).
/* Close the port */
run ClosePrinter( INPUT hprinter ).
END.
/* Clean Up */
SET-SIZE(pPrinterEnum) = 0.
SET-SIZE(pPrinterInfo) = 0.
SET-SIZE(lpPrinterName) = 0.
end procedure.
procedure p_show_printers:
define variable tofile as logical initial yes no-undo.
if tofile then output to value (output_file).
for each t_printer :
if tofile then export t_printer.
else message
t_printer.printername skip
t_printer.printerport skip
t_printer.printerhandle skip
t_printer.printerhprinter skip
t_printer.printerstatus skip
t_printer.printerdriver skip
view-as alert-box.
end.
if tofile then output close.
end procedure.

 
Hi itflude,

Thanks for your reply.

I have already started looking at extracting the windows printer bits and putting them into a temp-table as you have suggested.

Regards

Mike
 
Top