Vista Printing issue

Vista Printing issue

Postby don lowenstein » Tue Oct 06, 2009 6:26 pm

I am trying to print to a printer other than the windows default printer - in vista.

The technique used works fine in xp and before - however in vista - the Message Stop dialog appears as follows:
There are no printers installed!
Please exit this application and install a printer.
This message is coming from the TPRINTERS:NEW method
- and, in this particular scenario, there are several printers installed.

The following is the call to the Tprinter:new Method:
ODEVICE := TPRINTER():NEW( 'Report Name', .F., NIL, PRINTERNAME )
where PRINTERNAME is the name of the printer to use as acquired from the PRINTERSETUP() function as follows:
PRINTERSETUP()
hDC := GetPrintDefault( GetActiveWindow() )
PRINTERNAME := PRNGETNAME()

If, however in the vista environment,
I call Tprinter:new with the 2cnd parameter to force the printer selection dialog - all seems to work fine.
ODEVICE := TPRINTER():NEW( 'Report Name', .T.)

This is undesireable due to the additional interaction (Printer selection dialog) with the user which should not be required,
as we know what printer to use.

Any help with this issue is GREATLY appreciated.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: Vista Printing issue

Postby Richard Chidiak » Tue Oct 06, 2009 7:10 pm

Don

You need more than just prngetname() for this

This is the function i use, it works on both Vista and Xp

This is a sample of what is needed to print

// HP Deskjet F300 Series,winspool,Ne01:

HTH

Richard


AIMPRI := GETIMPRI(@AIMPRI)

OPRN := TPrinter():New(" Impression", .F. , .T. , AIMPRI[1] , .T. )


FUNCTION GETIMPRI(ADEVICES)
*----------------------------------------
LOCAl cAllEntries, cEntry, I, cName, cPrn, cPort, J

cAllEntries := STRTRAN( GetProfString( "Devices" ), Chr( 0 ), CRLF )
FOR I:= 1 TO MlCount( cAllEntries )
cName := MemoLine( cAllEntries,,I)
cEntry := GetProfString( "Devices",cName,"")
J := 2
WHILE ! EMPTY(cPort := StrToken(cEntry,J++,","))
// AADD(aDevices,TRIM(cName))
AADD(aDevices,TRIM(cName) + "," + CENTRY) // CHIDIAK
ENDDO
NEXT
RETURN aDevices
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Vista Printing issue

Postby don lowenstein » Wed Oct 07, 2009 6:58 pm

Thank you Richard - This appears to be working now.

I guess XP and before are forgiving about the name passed to TPrinter object.

Thanks again for your assistance.
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 60 guests