Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printer Dialog Form - Part 2C

What VB shoud be able to do!

Printer Dialog Form - Part 2C

by  CassandraR  Posted    (Edited  )
Continued from Part 2B -- mdlPrinterAccess.bas
Code:
'----------------------------------------------------------------------------------------
' Procedure : ParsePrinterStatus
' Date      : 18 May 2003
' Author    : Cassandra Roads, P. Eng.
' Copyright (c) 2003 Professional Logics Corporation
'----------------------------------------------------------------------------------------
'
Private Sub ParsePrinterStatus(ByRef strPrinterStatus As String, ByVal lngStatus As Long)

    Dim lngPower As Long, intBit As Integer, strBuilder As String, strBrick As String
    '
    '   Due to the simplistic nature of this sub, no pseudocode was created.
    '
    If lngStatus > 0 Then
        strBuilder = ""
        For intBit = 0 To 15
            lngPower = 2 ^ intBit
            strBrick = ""
            Select Case (lngPower And lngStatus)
                Case PRINTER_STATUS_PAUSED
                    strBrick = "Paused"
                Case PRINTER_STATUS_ERROR
                    strBrick = "Error"
                Case PRINTER_STATUS_PENDING_DELETION
                    strBrick = "Pending Deletion"
                Case PRINTER_STATUS_PAPER_JAM
                    strBrick = "Paper Jam"
                Case PRINTER_STATUS_PAPER_OUT
                    strBrick = "Paper Out"
                Case PRINTER_STATUS_MANUAL_FEED
                    strBrick = "Manual Feed"
                Case PRINTER_STATUS_PAPER_PROBLEM
                    strBrick = "Paper Problem"
                Case PRINTER_STATUS_OFFLINE
                    strBrick = "Offline"
                Case PRINTER_STATUS_IO_ACTIVE
                    strBrick = "IO Active"
                Case PRINTER_STATUS_BUSY
                    strBrick = "Busy"
                Case PRINTER_STATUS_PRINTING
                    strBrick = "Printing"
                Case PRINTER_STATUS_OUTPUT_BIN_FULL
                    strBrick = "Output Bin Full"
                Case PRINTER_STATUS_NOT_AVAILABLE
                    strBrick = "Not Available"
                Case PRINTER_STATUS_WAITING
                    strBrick = "Waiting"
                Case PRINTER_STATUS_PROCESSING
                    strBrick = "Processing"
                Case PRINTER_STATUS_INITIALIZING
                    strBrick = "Initializing"
                Case PRINTER_STATUS_WARMING_UP
                    strBrick = "Warming Up"
                Case PRINTER_STATUS_TONER_LOW
                    strBrick = "Toner Low"
                Case PRINTER_STATUS_NO_TONER
                    strBrick = "No Toner"
                Case PRINTER_STATUS_PAGE_PUNT
                    strBrick = "Page Punt"
                Case PRINTER_STATUS_USER_INTERVENTION
                    strBrick = "User Intervention"
                Case PRINTER_STATUS_OUT_OF_MEMORY
                    strBrick = "Out Of Memory"
                Case PRINTER_STATUS_DOOR_OPEN
                    strBrick = "Door Open"
            End Select
            If Len(strBrick) > 0 Then
                strBuilder = strBuilder & vbCrLf & strBrick
            End If
        Next intBit
        If Len(strBuilder) > 0 Then
            MsgBox "Printer reports: " & strBuilder, vbExclamation, _
                    "Printer Select"
        End If
    Else
        strPrinterStatus = "Ready"
    End If
End Sub
'
'----------------------------------------------------------------------------------------
'

'----------------------------------------------------------------------------------------
' Procedure : DerefStringPointer
' Date      : 18 May 2003
' Author    : Cassandra Roads, P. Eng.
' Copyright (c) 2003 Professional Logics Corporation
'----------------------------------------------------------------------------------------
'
Private Function DerefStringPointer(lngString As Long, lngMaxLen As Long) As String

    Dim strReturnString As String
    Dim lngRet As Long
    '
    '   If there is no string passed in, then exit.
    '   Use IsBadStringPtrLng to determine whether the string is actually a valid string.
    '   Prepare the strReturnString variable to receive the string.
    '   Copy the string, and possibly a bit more, into the strReturnString variable.
    '   If the DLL has not flagged an error (the string was copied) then
    '       Search for C's Null character that terminates the string.
    '       Trim strReturnString to proper length, "disconnecting" the extra bytes.
    '   Return the extract string.
    '------------------------------------------------------------------------------------
    '
    DerefStringPointer = ""
    strReturnString = ""
    
    If lngString = 0 Then Exit Function
    '
    If IsBadStringPtrLng(lngString, lngMaxLen) Then Exit Function
    '
    strReturnString = Space(lngMaxLen)
    '
    CopyMemory ByVal strReturnString, ByVal lngString, ByVal Len(strReturnString)
    '
    If Err.LastDllError = 0 Then
        If InStr(1, strReturnString, Chr(0)) > 0 Then
            strReturnString = Left(strReturnString, InStr(strReturnString, Chr(0)) - 1)
        End If
    End If
    '
    DerefStringPointer = strReturnString
    '
End Function
'
'----------------------------------------------------------------------------------------
'
End of mdlPrinterAccess.bas
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top