Donnerstag, 4. November 2010

Druckerinformationen mit VFP Bordmitteln / Display printer infos with native VFP functions

Vor einiger Zeit hatte ich bereits in zwei Einträgen über die Anzeige des aktuellen Druckerstatus (Teil1 , Teil2 )geschrieben. Die dort vorgestellten Funktionen arbeiten auf Basis der Windows Management Instrumentation (WMI).
Die heutige Funktion kommt ohne WMI aus. Sie greift auf zwei native VFP Funktionen zu: GETPRINTER() und PRTINFO().

Die Funktion PRTINFO() kennt insgesamt 13 verschiedene Parameterwerte die uns über die aktuellen Einstellungen des zuvor mit GETPRINTER() ausgewählten Druckers Auskunft geben. Dummerweise gibt es aber in fast allen Rückmeldungen wiederum nur einfache Zahlenwerte die wir dann mühselig über die Hilfe nachschlagen müssen.

Die folgende Funktion AnalyzePrtInfo() schlüsselt diese Daten in Textinformationen auf. Liefert ein Drucker keine Kenndaten zu einem bestimmten Abfragewert zurück, dann wird dies mit 'n.v.' (=nicht verfügbar) quittiert.

* // Funktionstest START
CLEAR 
lcPrinter = GETPRINTER()
?lcPrinter
FOR i = 1 TO 13
    ? AnalyzePrtInfo( i , PRTINFO( i , lcPrinter ) )
ENDFOR 
* // Funktionstest ENDE 

FUNCTION AnalyzePrtInfo as String
LPARAMETERS vParam as Integer , vValue as Integer
    LOCAL lcTitel as String , lcReturn as String
    STORE [] TO lcTitel , lcReturn
    DO CASE 
    *!*    1    Paper orientation
    CASE vParam = 1
        lcTitel = [Papierausrichtung]
        DO CASE
        CASE vValue = 0
            lcReturn = [Portrait (Hoch)]
        CASE vValue = 1
            lcReturn = [Landscape (Quer)]
        OTHERWISE
            lcReturn = [n.v.]
        ENDCASE
    *!*    2    Paper size 
    CASE vParam = 2
        lcTitel = [Papierformat]
        DO CASE 
        CASE vValue = 1
            lcReturn = [Letter, 8 1/2 x 11 inch]
        CASE vValue = 2
            lcReturn = [Letter Small, 8 1/2 x 11 inch]
        CASE vValue = 3
            lcReturn = [Tabloid, 11 x 17 inch]
        CASE vValue = 4
            lcReturn = [Ledger, 17 x 11 inch]
        CASE vValue = 5
            lcReturn = [Legal, 8 1/2 x 14 inch]
        CASE vValue = 6
            lcReturn = [Statement, 5 1/2 x 8 1/2 inch]
        CASE vValue = 7
            lcReturn = [Executive, 7 1/4 x 10 1/2 inch]
        CASE vValue = 8
            lcReturn = [A3, 297 x 420 mm]
        CASE vValue = 9
            lcReturn = [A4, 210 x 297 mm]
        CASE vValue = 10
            lcReturn = [A4, Small 210 x 297 mm]
        CASE vValue = 11
            lcReturn = [A5, 148 x 210 mm]
        CASE vValue = 12
            lcReturn = [B4, 250 x 354 mm]
        CASE vValue = 13
            lcReturn = [B5, 182 x 257 mm]
        CASE vValue = 14
            lcReturn = [Folio, 8 1/2 x 13 inch]
        CASE vValue = 15
            lcReturn = [Quarto, 215 x 275 mm]
        CASE vValue = 16
            lcReturn = [10 x 14 inch]
        CASE vValue = 17
            lcReturn = [11 x 17 inch]
        CASE vValue = 18
            lcReturn = [Note, 8 1/2 x 11 inch]
        CASE vValue = 19
            lcReturn = [Envelope #9, 3 7/8 x 8 7/8 inch]
        CASE vValue = 20
            lcReturn = [Envelope #10, 4 1/8 x 9 1/2 inch]
        CASE vValue = 21
            lcReturn = [Envelope #11, 4 1/2 x 10 3/8 inch]
        CASE vValue = 22
            lcReturn = [Envelope #12, 4 1/2 x 11 inch]
        CASE vValue = 23
            lcReturn = [Envelope #14, 5 x 11 1/2 inch]
        CASE vValue = 24
            lcReturn = [C size sheet]
        CASE vValue = 25
            lcReturn = [D size sheet]
        CASE vValue = 26
            lcReturn = [E size sheet]
        CASE vValue = 27
            lcReturn = [Envelope DL, 110 x 220 mm]
        CASE vValue = 28
            lcReturn = [Envelope C5, 162 x 229 mm]
        CASE vValue = 29
            lcReturn = [Envelope C3, 324 x 458 mm]
        CASE vValue = 30
            lcReturn = [Envelope C4, 229 x 324 mm]
        CASE vValue = 31
            lcReturn = [Envelope C6, 114 x 162 mm]
        CASE vValue = 32
            lcReturn = [Envelope C65, 114 x 229 mm]
        CASE vValue = 33
            lcReturn = [Envelope B4, 250 x 353 mm]
        CASE vValue = 34
            lcReturn = [Envelope B5, 176 x 250 mm]
        CASE vValue = 35
            lcReturn = [Envelope B6, 176 x 125 mm]
        CASE vValue = 36
            lcReturn = [Envelope, 110 x 230 mm]
        CASE vValue = 37
            lcReturn = [Envelope Monarch, 3 7/8 x 7.5 inch]
        CASE vValue = 38
            lcReturn = [6 3/4 Envelope, 3 5/8 x 6 1/2 inch]
        CASE vValue = 39
            lcReturn = [US Std Fanfold, 14 7/8 x 11 inch]
        CASE vValue = 40
            lcReturn = [German Std Fanfold, 8 1/2 x 12 inch]
        CASE vValue = 41
            lcReturn = [German Legal Fanfold, 8 1/2 x 13 inch]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    3    Paper length in .1 millimeter increments
    CASE vParam = 3
        lcTitel = [Papierlänge]
        DO CASE 
        CASE vValue >= 0
            lcReturn = TRANSFORM( vValue ) +  [ .1 mm]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    4    Paper width in .1 millimeter increments
    CASE vParam = 4
        lcTitel = [Papierbreite]
        DO CASE 
        CASE vValue >= 0
            lcReturn = TRANSFORM( vValue ) +  [ .1 mm]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    5    Factor by which printer output is scaled
    CASE vParam = 5
        lcTitel  = [Skalierung]
        DO CASE 
        CASE vValue >= 0
            lcReturn = TRANSFORM( vValue ) + [ %]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    6    Number of copies to print
    CASE vParam = 6
        lcTitel  = [Anzahl Kopien]
        DO CASE 
        CASE vValue >= 0
            lcReturn = TRANSFORM( vValue )
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    7    Default paper source
    CASE vParam = 7
        lcTitel  = [Schacht]
        DO CASE 
        CASE vValue = 1
            lcReturn = [Oberer Schacht]
        CASE vValue = 2
            lcReturn = [Unterer Schacht]
        CASE vValue = 3
            lcReturn = [Mittlerer Schacht]
        CASE vValue = 4
            lcReturn = [Manueller Einzug]
        CASE vValue = 5
            lcReturn = [Briefumschlag Einzug]
        CASE vValue = 6
            lcReturn = [Manueller Briefumschlag Einzug]
        CASE vValue = 7
            lcReturn = [Automatischer Einzug]
        CASE vValue = 8
            lcReturn = [Traktoreinzug]
        CASE vValue = 9
            lcReturn = [Kleinformat]
        CASE vValue = 10
            lcReturn = [Großformat]
        CASE vValue = 11
            lcReturn = [Große Kapazität]
        CASE vValue = 14
            lcReturn = [Kassette]
        CASE vValue = 15
            lcReturn = [Standardeinzug (automatisch)]
         OTHERWISE 
            lcReturn = [n.v.]
         ENDCASE 
    *!*    8    A positive value that indicates the horizontal resolution
    *!*        in dots per inch (DPI) or a negative value that indicates
    *!*        the print quality.
    CASE vParam = 8
        lcTitel  = [Auflösung]
        DO CASE 
        CASE vValue = -1
            lcReturn = [Draft]
        CASE vValue = -2
            lcReturn = [Niedrig]
        CASE vValue = -3
            lcReturn = [Mittel]
        CASE vValue = -4
            lcReturn = [Hoch]
        OTHERWISE 
            lcReturn = TRANSFORM( vValue ) + [ DPI]
        ENDCASE         
    *!*    9    A value that indicates if a color printer rends color or
    *!*        monochrome output
    CASE vParam = 9
        lcTitel  = [Ausgabe]
        DO CASE 
        CASE vValue = 1
            lcReturn = [monochrome]
        CASE vValue = 2
            lcReturn = [farbig]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    10    Duplex mode
    CASE vParam = 10
        lcTitel  = [Druckausgabe]
        DO CASE 
        CASE vValue = 1
            lcReturn = [Simplex Druck]
        CASE vValue = 2
            lcReturn = [Vertikaler Duplexdruck]
        CASE vValue = 3
            lcReturn = [Horizontaler Duplexdruck]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    11    The vertical resolution in dots per inch (DPI). If not
    *!*        available, a value of -1 is returned.
    CASE vParam = 11
        lcTitel  = [vertik. Auslösung]
        DO CASE 
        CASE vValue >= 0
            lcReturn = TRANSFORM( vValue ) + [ DPI]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    *!*    12    A value that indicates how TrueType® fonts are printed
    CASE vParam = 12
        lcTitel  = [Truetype Schriften]
        DO CASE 
        CASE vValue = 1
            lcReturn = [Druck als Bitmap Grafik]
        CASE vValue = 2
            lcReturn = [Druck über Softfonts]
        CASE vValue = 3
            lcReturn = [Druck über Ersatzfonts]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE  
    *!*    13    A value that indicates if output is collated
    CASE vParam = 13
        lcTitel  = [Sammeldruck]
        DO CASE 
        CASE vValue = 0
            lcReturn = [nein]
        CASE vValue = 1
            lcReturn = [ja]
        OTHERWISE 
            lcReturn = [n.v.]
        ENDCASE 
    ENDCASE 
    RETURN PADR( lcTitel , 20 , [ ] ) + [: ] + lcReturn
ENDFUNC 

Keine Kommentare:

Kommentar veröffentlichen