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 >
Wrap
Text File
|
1994-09-23
|
3KB
|
70 lines
#include "windows.ch"
#include "print.ch"
#define DEVICE_NAME 1
#define DRIVER_NAME 2
#define DEVICE_PORT 3
static hWnd, hInst, hPrevInst, nCmdShow
static cAppName := "PrintDC"
FUNCTION Main()
LOCAL hPrintDC
LOCAL aPrinter
LOCAL aDEVMODE := ARRAY( 18 )
hWnd := WinSetup(cAppName, "PrintDC Test")
aPrinter := GetPrinterInfo()
aDEVMODE[ DM_DeviceName ] := aPrinter[ DEVICE_NAME ]
aDEVMODE[ DM_SpecVersion ] := aPrinter[ DRIVER_NAME ]
aDEVMODE[ DM_DriverVersion ] := aPrinter[ DEVICE_PORT ]
aDEVMODE[ DM_Size ] := NIL // Not used/Reserved
aDEVMODE[ DM_DriverExtra ] := NIL // Not used/Reserved
aDEVMODE[ DM_Fields ] := NIL // Not used/Reserved
aDEVMODE[ DM_Orientation ] := DMORIENT_LANDSCAPE
aDEVMODE[ DM_PaperSize ] := NIL
aDEVMODE[ DM_PaperLength ] := NIL
aDEVMODE[ DM_PaperWidth ] := NIL
aDEVMODE[ DM_Scale ] := NIL
aDEVMODE[ DM_Copies ] := 2
aDEVMODE[ DM_DefaultSource ] := NIL
aDEVMODE[ DM_PrintQuality ] := NIL
aDEVMODE[ DM_Color ] := NIL
aDEVMODE[ DM_Duplex ] := NIL
aDEVMODE[ DM_YResolution ] := NIL
aDEVMODE[ DM_TTOption ] := NIL
hPrintDC := PrinterDC( aDEVMODE, DM_IN_BUFFER+DM_OUT_BUFFER )
// If an error occurs then hPrintDC will be 0
// you should test before using!
IF hPrintDC > 0
IF MessageBox( , "Test Printer?", "PrintDC Ok", MB_YESNO ) == IDYES
StartDoc(hPrintDC, "TestOutput")
StartPage(hPrintDC)
TextOut(hPrintDC, 10, 10, "Test")
EndPage(hPrintDC)
EndDoc(hPrintDC)
DeleteDC(hPrintDC) // Don't forget to delete this!
ENDIF
ELSE
MessageBox(, "Invalid hPrintDC!", "Error" )
ENDIF
RETURN( NIL )
STATIC FUNCTION GetPrinterInfo
LOCAL cPrintInfo, cDevice, cPort, cDriver
cPrintInfo := GetProfString( "windows", "device", "" )
cDevice := ALLTRIM( LEFT( cPrintInfo, AT( ",", cPrintInfo ) - 1 ) )
cPrintInfo := SUBSTR( cPrintInfo, AT( ",", cPrintInfo ) + 1 )
cDriver := ALLTRIM( LEFT( cPrintInfo, AT( ",", cPrintInfo ) - 1) ) + ".DRV"
cPrintInfo := SUBSTR( cPrintInfo, AT( ",", cPrintInfo ) + 1 )
cPort := cPrintInfo
RETURN( { cDevice, cDriver, cPort } )