Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Barbara Peisch
  Where is Barbara Peisch?
 Oceanside
 California - United States
 Barbara Peisch
 To: Anand G
  Where is Anand G?
 chennai
 India
 Anand G
 Tags
Subject: RE: SYS(1037) not having printers button
Thread ID: 158140 Message ID: 158197 # Views: 10 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Friday, January 25, 2008 8:20:31 PM         
   


> In VISTA the page setup dialog invoked through SYS(1037) does not have the "Printers.." button. This button launches the print setup dialog.
>
> Using GETPRINTER() launches the print setup but without "Properties" button that would bring up the unique properties page(s) for selected printer.

I don't know why there's a problem with SYS(1037) in Vista, but until you find out, maybe you can work around the problem by using the DocumentProperties API instead. (I haven't tried this so I don't know if it works in Vista or not.)

* Lets the user set all possible printer properties
LOCAL lcRptFile, lhWindow, lcOrigDevMode, lcModifiedDevMode, lcPrinter, lhPrinter

* These constants come from the Windows.h file
#DEFINE IDOK     1
#DEFINE IDCANCEL 2

#DEFINE DM_OUT_BUFFER 2
#DEFINE DM_IN_BUFFER  8
#DEFINE DM_IN_PROMPT  4

DECLARE INTEGER OpenPrinter IN winspool.drv ;
      STRING pPrinterName, ;
      INTEGER @phPrinter, ;
      INTEGER pDefault

DECLARE INTEGER GetActiveWindow IN user32

DECLARE INTEGER DocumentProperties IN winspool.drv ;
      INTEGER hWnd, ;
      INTEGER hPrinter, ;
      STRING pDeviceName, ;
      STRING @pDevModeOutput, ;
      STRING @pDevModeInput, ;
      INTEGER fMode

DECLARE INTEGER ClosePrinter IN winspool.drv INTEGER hPrinter 

* If your form doesn't have a combo to select the printer, substitute 
* some other way to desinate the printer.
lcPrinter = ALLTRIM(thisform.cboName.Value)
IF NOT EMPTY(lcPrinter)
   lhWindow = GetActiveWindow()

   * If we have a printer open from a previous call, close it so we don't
   * keep extra handles open.
   IF NOT ISNULL(Thisform.hPrinter) AND NOT EMPTY(Thisform.hPrinter)
      lhPrinter = thisform.hPrinter
      ClosePrinter(lhPrinter)
   ENDIF 

   lhPrinter = 0
   OpenPrinter(lcPrinter, @lhPrinter, 0)
   IF lhPrinter = 0
      Messagebox("Could not open printer.", 48, "Error")
      RETURN
   ELSE
      Thisform.hPrinter = lhPrinter
   ENDIF

   * Use a unique file name so we can use this in a multi-user situation
   * Using a cursor instead of a physical file doesn't work, but we can
   * create the FRX from a cursor.
   lcRptFile = SYS(2015)+".FRX"
   CREATE CURSOR TempCur (Temp C (10))
   CREATE REPORT (JUSTSTEM(lcRptFile)) FROM TempCur
   USE IN TempCur
   USE (lcRptFile) EXCLUSIVE ALIAS RptFile

   IF EMPTY(Thisform.cOldExpr)
      * Use SYS(1037,2) to read the printer settings instead of DocumentProperties
      SYS(1037,2)

      * We only want to save the original settings the first time
      Thisform.cOldExpr = EXPR
      Thisform.cOldTag  = TAG
      Thisform.cOldTag2 = TAG2
      lcOrigDevmode     = TAG2
      Thisform.cDevMode = TAG2
      lcModifiedDevmode = TAG2
   ELSE 
      lcOrigDevmode     = Thisform.cDevmode
      lcModifiedDevmode = Thisform.cDevmode
   ENDIF 

   * Show printer settings dialog.
   lnResult = DocumentProperties(lhWindow, lhPrinter, lcPrinter, @lcModifiedDevmode, @lcOrigDevmode, DM_IN_PROMPT+DM_IN_BUFFER+DM_OUT_BUFFER)

   IF lnResult <> IDCANCEL
      * Set the printer to the new options
      SELECT RptFile
      replace expr WITH '', ;
              tag WITH '', ;
              tag2 WITH lcModifiedDevmode
      thisform.cDevMode = lcModifiedDevmode
      SYS(1037,3)		&& Writes the printer settings out to the printer
   ENDIF 
   * Get rid of the temporary FRX
   USE IN RptFile
   ERASE (JUSTSTEM(lcRptFile)+".*")
ENDIF 


-BP
www.peisch.com

ENTIRE THREAD

SYS(1037) not having printers button Posted by Anand G @ 1/25/2008 2:33:12 PM
RE: SYS(1037) not having printers button Posted by Barbara Peisch @ 1/25/2008 8:20:31 PM