locked
get printer() doesn't "get" the printer in VFP 9.0 RRS feed

  • Question

  • When I choose a printer using the getprinter() function, I choose a printer and it doesn't select it. It stays with the default printer setting, why? I do not want to use the printer prompt in my code.
    Larry Nunez
    Monday, August 1, 2011 12:29 PM

Answers

All replies

  • GetPrinter() does not select the printer in Windows/VFP. It just allows to display a list and select one item from that list. To set this printer as Windows default you would need to call Win32 API. To set this printer as default for FoxPro you have to issue SET PRINTER TO NAME command, e.g.:

    SET PRINTER TO NAME GetPrinter()

     

    • Marked as answer by Larry_Nuñez Monday, August 1, 2011 9:25 PM
    Monday, August 1, 2011 12:47 PM
  • Hi Larry

    Try the following:

    prntname = getprinter()
    if !empty(prntname)
       set printer to name prntname
    endif
    ...
    ,,,
    set printer to default  && do this when done to reset the printer


    Hope that helps


    Mike z
    Monday, August 1, 2011 12:50 PM
  • This code doesn't even display the dialog box to select the printer
    Larry Nunez
    Monday, August 1, 2011 2:43 PM
  • This code doesn't even display the dialog box to select the printer
    What code?
    • Marked as answer by Larry_Nuñez Monday, August 1, 2011 9:26 PM
    • Unmarked as answer by Martin_Xie Tuesday, August 2, 2011 1:09 AM
    Monday, August 1, 2011 4:46 PM
    • Proposed as answer by Naomi N Monday, August 1, 2011 6:32 PM
    • Marked as answer by Larry_Nuñez Monday, August 1, 2011 9:26 PM
    Monday, August 1, 2011 4:52 PM
  •  the last code you wrote will not display the dialog box so that I can select it
    It could mean there are no 32 bit printer drivers installed on that machine.
    • Marked as answer by Larry_Nuñez Monday, August 1, 2011 9:26 PM
    Monday, August 1, 2011 4:53 PM
  • It needs to be in () in both yours and Pavel's code, e.g.

     

     

    prntName = getprinter()
    
    if not empty(m.prntName)
    
       set printer to name (m.prntName)
    
    endif

     


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog
    Monday, August 1, 2011 5:38 PM
  • It needs to be in () in both yours and Pavel's code, e.g.

    No, it is necessary just in Michael's case. GETPRINTER() is recognized as an expression without parentheses.

    But this isn't problem as I understood. The GetPrinter() does not show the list of available pronters probably.

    • Marked as answer by Larry_Nuñez Monday, August 1, 2011 9:26 PM
    Monday, August 1, 2011 6:10 PM
  • Initially you say "When I choose a printer using the getprinter() function, I choose a printer and it doesn't select it."

     Well now, how can the getprinter() function give you a dialog to choose a printer first, and now it does not?

    The Getrpinter() function does list printers for choice, but it doesn't choose and set a printer, that is up to SET PRINTER. This is the problem, plus the problem of 32bit vs 64bit drivers. Foxpro can only see and use 32bit printer drivers.

    Bye, Olaf.


    • Proposed as answer by Naomi N Monday, August 1, 2011 7:19 PM
    • Unproposed as answer by Larry_Nuñez Monday, August 1, 2011 9:26 PM
    Monday, August 1, 2011 6:39 PM