No Printers installed

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

No Printers installed

Post by StefanHaupt »

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

.....
    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
Jonathan Hodder
Posts: 77
Joined: Sun Aug 26, 2007 11:53 pm

Re: No Printers installed

Post by Jonathan Hodder »

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
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: No Printers installed

Post by StefanHaupt »

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

oDevice := TPrinter():New(...)
REPORT oReport .... TO DEVICE oDevice
kind regards
Stefan
Post Reply