Datamax-O'Neil Class Series Programmer’s Manual User Manual

Page 170

Advertising
background image

Appendix B – Sample Programs

Class Series Programmer’s Manual

156

Private Declare Function StartPagePrinter& Lib “winspool.drv” (ByVal
hPrinter As Long)
Private Declare Function WritePrinter& Lib “winspool.drv” (ByVal
hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, pcWritten As Long)
Private Declare Function EndDocPrinter& Lib “winspool.drv” (ByVal
hPrinter As Long)
Private Declare Function EndPagePrinter& Lib “winspool.drv” (ByVal
hPrinter As Long)
Private Declare Function ClosePrinter& Lib “winspool.drv” (ByVal
hPrinter As Long)
#End If ‘WIN32

Dim ch As String * 1, f1 As Integer, loadfile As String
Private Sub cmdOpenFile_Click()
On Error GoTo ErrHandler
‘ Set Filters
CommonDialog1.Filter = “All Files (*.*)|*.*”
‘Specify Default Filter
CommonDialog1.FilterIndex = 1
‘Display Open dialog box
CommonDialog1.ShowOpen
loadfile = CommonDialog1.FileName
Label2.Caption = loadfile
Exit Sub

ErrHandler:
Exit Sub
End Sub
Private Sub cmdStoreImage_Click()
Dim hPrinter&
Dim jobid&
Dim res&
Dim written&
Dim printdata$
Dim docinfo As DOC_INFO_1

loadfile = Form1.txtFile.Text
If loadfile = ““ Then
MsgBox “You must Open a file to send”, vbExclamation
Exit Sub
End If

‘ Open file.
f1 = FreeFile
Open loadfile For Binary As f1

‘ Open printer for printing
res& = OpenPrinter(SelPrinter, hPrinter, 0)
If res = 0 Then
MsgBox “Unable to open the printer”
Exit Sub

Advertising