INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Visual Basic (Microsoft) Versions 5/6 FAQ

What VB shoud be able to do!

Printer Dialog Form - Part 2C by CassandraR
Posted: 9 Oct 03

Continued from Part 2B -- mdlPrinterAccess.bas


'----------------------------------------------------------------------------------------
' 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

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close