Can not Print in Vista SP1.

Post Reply
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Can not Print in Vista SP1.

Post by Patrick Mast »

Hello,

In Windows Vista with Service Pack 1, I always get this message:
Image

Looking in printer.prg, I see it's because of this code:

Code: Select all

elseif ComDlgXErr() != 0
      MsgStop( "There are no printers installed!"  + CRLF + ;
               "Please exit this application and install a printer." )
Is anyone else experience this problem. And if so, how can we solve it?

Thanks!

Patrick[/img]
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Post by Marco Turco »

Hi Patrick,
is your printer a local or a network printer ?

Windows Vista is not very fast to active the network connections at startup so you have to give the time to make this before start your app if only network printers are availables on your workstation.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Marco Turco wrote:is your printer a local or a network printer ?
Local printer.

Patrick
User avatar
Kleyber
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Post by Kleyber »

Patrick Mast wrote:
Marco Turco wrote:is your printer a local or a network printer ?
Local printer.

Patrick
Hi, Patrick,

I had this problem specially after updating to SP2. At the first time, it prints ok, but on the second time, it gives me this error. If you come back to SP1 there is no problem. So, it seems to be a Vista problem (and a serious problem!). Because of this I had to come back to XP.

Regards,
Kleyber Derick

FWH / xHb / xDevStudio / SQLLIB
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

I had this problem specially after updating to SP2. At the first time, it prints ok, but on the second time, it gives me this error. If you come back to SP1 there is no problem. So, it seems to be a Vista problem (and a serious problem!). Because of this I had to come back to XP.
But we have too many clients who are upgrading to Vista and I can not tell my customres to downgrade their OS.

Antonio? Can you help us?

Thanks!

Patrick
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Post by Richard Chidiak »

Patrick,

I have been through this one last week

The problem comes from identifying the printer

if you are printing to a specifief printer and just passing the printer's name before (as i was doing), you will get the message.

You have to pass now the port also, and it will work ok.

It works also as backward's compatibility (vista without sp1 and xp)

Below is my printer selection function

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


HTH

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
MOISES
Posts: 824
Joined: Wed Aug 22, 2007 10:09 am

Post by MOISES »

Hi,

This error occurs, for example, when printing from PREVIEW?.

Best regards,
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Post by Richard Chidiak »

This error occurs on vista sp1 when you print without prompting the user for the printer, to an identified printer by it's name

it occurs before preview

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Richard Chidiak wrote:I have been through this one last week
The problem comes from identifying the printer
if you are printing to a specifief printer and just passing the printer's name before (as i was doing), you will get the message.
You have to pass now the port also, and it will work ok.
You mean, instead of doing this:

Code: Select all

oPrn:=TPrinter():New("Testpage",.f.,.f.,"HP xyz")
We now have to do:

Code: Select all

oPrn:=TPrinter():New("Testpage",.f.,.f.,"HP xyz,winspool,LPT1:")
Is this correct?

Thanks!

Patrick
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Post by Richard Chidiak »

Patrick,

Yes , this is the way to go if you print without prompting the user to select a printer, if you prompt for printer selection, the old syntax works ok

gotta love vista !

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Patrick Mast
Posts: 244
Joined: Sat Mar 03, 2007 8:42 pm

Post by Patrick Mast »

Richard Chidiak wrote:Yes , this is the way to go if you print without prompting the user to select a printer, if you prompt for printer selection, the old syntax works ok

gotta love vista !
Thank you Richard!

Patrick
User avatar
Manuel Valdenebro
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

Re:

Post by Manuel Valdenebro »

Richard Chidiak wrote: You have to pass now the port also, and it will work ok.
Below is my printer selection function

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

HTH

Richard
Richard,

I have a function, including in the previeus, to change on line the printer. This is the code:

func f_CamImpre (oDevice, cCbx )
local cPrinter

// impresora predeterminada
cPrinter := GetProfString( "windows", "device" , "" )
// instalamos la impresora elegida
WriteProfString( "windows", "device", cCbx )
// refrescamos el sistema
SysRefresh()
//iniciamos impresora
PrinterInit()

DeleteDC( oDevice:hDC ) // Sugestion by Enrico M. Giordano

// temporal printer
oDevice:hDC := GetPrintDefault( GetActiveWindow() )

SysRefresh()
// default printer again
WriteProfString( "windows", "device", cPrinter )

RETURN nil

I have now, in Vista, second time that I try to print, the message "There are not printer inst..."

Can you help me to change that function to adding the port number?

Thanks and regards
Un saludo

Manuel
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Can not Print in Vista SP1.

Post by StefanHaupt »

Manuel,

I had a similar situation printing in Vista, did you read my post in this topic ?
http://forums.fivetechsupport.com/viewt ... =3&t=15485

Vista does not allow, to initialize the same printer twice, then the error occurs.
kind regards
Stefan
User avatar
Manuel Valdenebro
Posts: 706
Joined: Thu Oct 06, 2005 9:57 pm
Location: Málaga-España

Re: Can not Print in Vista SP1.

Post by Manuel Valdenebro »

StefanHaupt wrote: Vista does not allow, to initialize the same printer twice, then the error occurs.
Stefan,

But if I use standard rpreview it is correct.

Regards
Un saludo

Manuel
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Re:

Post by StefanHaupt »

Manuel Valdenebro wrote: I have now, in Vista, second time that I try to print, the message "There are not printer inst..."
Manuel,

as I said, vista does not allow to initialize the printer twice, if this error only occures on the second try to print the first printer object doesn´t seem to be finished. Did you correctly end your printer object ?

BTW, to get all installed printers you can use the function GetPrinters() from xharbour.

Code: Select all

aPrinter := GetPrinters()
IF lPreview
  PRINT oPrint NAME "Formular" PREVIEW TO aPrinter[xx]
ELSE
  PRINT oPrint NAME "Formular" TO aPrinter[xx]
ENDIF 
This is working fine for me.
kind regards
Stefan
Post Reply