home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / PRINTDC.ZIP / TEST.PRG < prev    next >
Text File  |  1994-09-23  |  3KB  |  70 lines

  1.  
  2. #include "windows.ch"
  3. #include "print.ch"
  4.  
  5. #define DEVICE_NAME  1
  6. #define DRIVER_NAME  2
  7. #define DEVICE_PORT  3
  8.  
  9. static  hWnd, hInst, hPrevInst, nCmdShow
  10. static  cAppName := "PrintDC"
  11.  
  12.  
  13. FUNCTION Main()
  14.        LOCAL  hPrintDC
  15.        LOCAL  aPrinter
  16.        LOCAL  aDEVMODE := ARRAY( 18 )
  17.  
  18.        hWnd         := WinSetup(cAppName, "PrintDC Test")
  19.  
  20.        aPrinter     := GetPrinterInfo()
  21.  
  22.        aDEVMODE[ DM_DeviceName    ] := aPrinter[ DEVICE_NAME ]
  23.        aDEVMODE[ DM_SpecVersion   ] := aPrinter[ DRIVER_NAME ]
  24.        aDEVMODE[ DM_DriverVersion ] := aPrinter[ DEVICE_PORT ]
  25.        aDEVMODE[ DM_Size          ] := NIL  // Not used/Reserved
  26.        aDEVMODE[ DM_DriverExtra   ] := NIL  // Not used/Reserved
  27.        aDEVMODE[ DM_Fields        ] := NIL  // Not used/Reserved
  28.        aDEVMODE[ DM_Orientation   ] := DMORIENT_LANDSCAPE
  29.        aDEVMODE[ DM_PaperSize     ] := NIL
  30.        aDEVMODE[ DM_PaperLength   ] := NIL
  31.        aDEVMODE[ DM_PaperWidth    ] := NIL
  32.        aDEVMODE[ DM_Scale         ] := NIL
  33.        aDEVMODE[ DM_Copies        ] := 2
  34.        aDEVMODE[ DM_DefaultSource ] := NIL
  35.        aDEVMODE[ DM_PrintQuality  ] := NIL
  36.        aDEVMODE[ DM_Color         ] := NIL
  37.        aDEVMODE[ DM_Duplex        ] := NIL
  38.        aDEVMODE[ DM_YResolution   ] := NIL
  39.        aDEVMODE[ DM_TTOption      ] := NIL
  40.  
  41.        hPrintDC     := PrinterDC( aDEVMODE, DM_IN_BUFFER+DM_OUT_BUFFER )
  42.  
  43.        // If an error occurs then hPrintDC will be 0
  44.        // you should test before using!
  45.  
  46.        IF  hPrintDC > 0
  47.            IF MessageBox( , "Test Printer?", "PrintDC Ok", MB_YESNO ) == IDYES
  48.               StartDoc(hPrintDC, "TestOutput")
  49.               StartPage(hPrintDC)
  50.               TextOut(hPrintDC, 10, 10, "Test")
  51.               EndPage(hPrintDC)
  52.               EndDoc(hPrintDC)
  53.               DeleteDC(hPrintDC)  // Don't forget to delete this!
  54.            ENDIF
  55.        ELSE
  56.            MessageBox(, "Invalid hPrintDC!", "Error" )
  57.        ENDIF
  58. RETURN( NIL )
  59.  
  60. STATIC FUNCTION GetPrinterInfo
  61.        LOCAL  cPrintInfo, cDevice, cPort, cDriver
  62.  
  63.        cPrintInfo   := GetProfString( "windows", "device", "" )
  64.        cDevice      := ALLTRIM( LEFT( cPrintInfo, AT( ",", cPrintInfo ) - 1 ) )
  65.        cPrintInfo   := SUBSTR( cPrintInfo, AT( ",", cPrintInfo ) + 1 )
  66.        cDriver      := ALLTRIM( LEFT( cPrintInfo, AT( ",", cPrintInfo ) - 1) ) + ".DRV"
  67.        cPrintInfo   := SUBSTR( cPrintInfo, AT( ",", cPrintInfo ) + 1 )
  68.        cPort        := cPrintInfo
  69. RETURN( { cDevice, cDriver, cPort } )
  70.