No Printers installed

No Printers installed

Postby StefanHaupt » Mon May 04, 2009 4:09 pm

Dear friends,

I have a problem printing reports on my notebook with Vista. I get the message "There are no printers installed. Please exit this ...".

In fact I have printers installed and there is also a default printer defined.

I found the reason for this error is in these lines in printer.prg
Code: Select all  Expand view
.....
    elseif cModel == nil
      ::hDC  := GetPrintDefault( GetActiveWindow() )
      if ::hDC != 0
        cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif
.....
  if ::hDC != 0
      aOffset    = PrnOffset( ::hDC )
      ::nXOffset = aOffset[ 1 ]
      ::nYOffset = aOffset[ 2 ]
      ::nOrient  = ::GetOrientation()
   elseif ComDlgXErr() != 0  // PDERR_NODEFAULTPRN = 0x1008 (4104)
      MsgStop( "There are no printers installed!"  + CRLF + ;
               "Please exit this application and install a printer." )
      ::nXOffset = 0
      ::nYOffset = 0
....


::lUser is .f., I don´t open a common dialog box

ComDlgXErr() returns 4104 (PDERR_NODEFAULTPRN), although GetPrintDefault() returns a correct handle and GetModel() returns the correct printer name of the default printer.

Why does ComDlgXErr() return an error code ?

Does anyone noticed this behavior ?
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: No Printers installed

Postby Jonathan Hodder » Tue May 05, 2009 9:14 pm

I recall having this problem a long time ago.
I think my problem was related to GetActiveWindow().
It was a one off program so I did not persue the problem.
I think I solved it by passing the main window through as
a static to replace the DC ie ... GetPrintDefault( n?? ).
Not good but it worked and thats all I needed.

Maybe this helps

JH
Jonathan Hodder
 
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Re: No Printers installed

Postby StefanHaupt » Wed May 06, 2009 11:08 am

Jonathan,

thanks for your hint, but finally I found the problem.

I called the report with REPORT oReport .... TO PRINTER and than I tried to define the device with oReport:oDevice := TPrinter ():New(...), where the report should be printed.

I found, that TPrinter ():New(...) was called twice, first in the report class and the second time from my function. This was working with XP, but with Vista the second call caused the error.

So my solution is now to define the device first and than call the report class.

Code: Select all  Expand view
oDevice := TPrinter():New(...)
REPORT oReport .... TO DEVICE oDevice
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 103 guests