Quelltexte/ Codesnippets | | | | | Und wer hats erfunden? Natürlich...
Andreas Miethe (17.12.10)
Hier ein alter ( 2000) Code von mir, vielleicht hilft es ja. KompilierenMarkierenSeparierenDef @AGetDeviceCaps(2) ! "GDI32","GetDeviceCaps"
Def @ACreateDC(4) ! "GDI32","CreateDCA"
Def @DeleteDC(1) ! "GDI32","DeleteDC"
Declare PDC&,APX!,APY!,PB!,PH!,POX!,POY!,DPIX!,DPIY!,PBMM!,PHMM!,RMM!
Declare PMAX!,PMAY!
Declare drv#,name#,port#
Declare device$,driv$,port$
Declare POR!,PUR!
Declare PLR!,PRR!
Proc GetPrinterDC
'Printer-DC ermitteln
DIM drv#,100
DIM name#,100
DIM port#,100
LET device$=@readini$("win.ini","windows","device")
LET device$=@substr$(@readini$("win.ini","windows","device"),1,",")
LET driv$= @substr$(@readini$("win.ini","devices",device$),1,",")+".drv"
LET port$=@substr$(@readini$("win.ini","devices",device$),2,",")
String name#,0=device$
String drv#,0=driv$
String port#,0=port$
Let PDC&=@ACreateDC(drv#,name#,port#,0)
dispose drv#
dispose name#
dispose port#
EndProc
Proc Werte_Ermitteln
'Werte ermitteln
Let APX!=@AGetDeviceCaps(PDC&,8)'Ausgabebreite in Pixel
Let APY!=@AGetDeviceCaps(PDC&,10)'AusgabeHoehe in Pixel
Let PB!=@AGetDeviceCaps(PDC&,110)'Physikalische Breite
Let PH!=@AGetDeviceCaps(PDC&,111)'Physikalische Hoehe
Let POX!=@AGetDeviceCaps(PDC&,112)'Offset X
Let POY!=@AGetDeviceCaps(PDC&,113)'Offset Y
Let DPIX!=@AGetDeviceCaps(PDC&,88)'DPI X
Let DPIY!=@AGetDeviceCaps(PDC&,90)'DPI Y
Let PBMM!=@AGetDeviceCaps(PDC&,4)'Ausgabebreite in mm
Let PHMM!=@AGetDeviceCaps(PDC&,6)'Ausgabehoehe in mm
EndProc
Proc Ausgabe
'Werte ausgeben
UseFont "Arial",18,0,1,0,0
Drawtext 10,0,"Standard-Drucker : "+Device$
UseFont "Courier New",15,0,0,0,0
if @AGetDeviceCaps(PDC&,2) = 2
Drawtext 10,20,"Rasterdrucker"
endif
Decimals 0
Drawtext 10,60,"Ausgabebreite in Pixel : "+str$(APX!)
Drawtext 340,60,"Ausgabehöhe in Pixel : "+str$(APY!)
Drawtext 10,80,"Physikalische Breite in Pixel : "+str$(PB!)
Drawtext 340,80,"Physikalische Höhe in Pixel : "+str$(PH!)
Drawtext 10,100,"Physikalische Offset X : "+str$(POX!)
Drawtext 340,100,"Physikalische Offset Y : "+str$(POY!)
Drawtext 10,120,"Aufloesung Breite (DPI) : "+str$(DPIX!)
Drawtext 340,120,"Aufloesung Höhe (DPI) : "+str$(DPIY!)
Drawtext 10,140,"Ausgabebreite in mm : "+str$(PBMM!)
Drawtext 340,140,"Ausgabebreite in mm : "+str$(PHMM!)
UseFont "Arial",18,0,1,0,1
DrawText 10,180,"Aus diesen ermittelten Werten lassen sich die Druckränder"
DrawText 10,200,"für den Standard-Drucker errechnen"
UseFont "Courier New",15,0,0,0,0
DrawText 10,240,"Linker Rand in Pixel : "+STR$(POX!)
DrawText 340,240,"Rechter Rand in Pixel : "+STR$((PB!-APX!)-POX!)
DrawText 10,260,"Oberer Rand in Pixel : "+STR$(POY!)
DrawText 340,260,"Unterer Rand in Pixel : "+STR$((PH!-APY!)-POY!)
Decimals 1
Let PLR!=ROUND((PBMM!/APX!)*POX!,1)
Let PRR!=ROUND(((PBMM!/APX!)*((PB!-APX!)-POX!)),1)
Let POR!=ROUND(((PHMM!/APY!)*POY!),1)
Let PUR!=ROUND(((PHMM!/APY!)*((PH!-APY!)-POY!)),1)
DrawText 10,280,"Linker Rand in mm : "+STR$(PLR!)
DrawText 340,280,"Rechter Rand in mm : "+STR$(PRR!)
DrawText 10,300,"Oberer Rand in mm : "+STR$(POR!)
DrawText 340,300,"Unterer Rand in mm : "+STR$(PUR!)
Decimals 0
DrawText 10,340,"Blattgrösse X in mm : "+STR$(((PBMM!+PLR!)+PRR!))
DrawText 340,340,"Blattgrösse Y in mm : "+STR$(((PHMM!+POR!)+PUR!))
Textcolor rgb(255,0,0),rgb(192,192,192)
UseFont "Courier New",16,0,1,0,0
If APX! > APY!
Drawtext 10,40,"Querformat"
else
Drawtext 10,40,"Hochformat"
endif
Textcolor rgb(255,255,0),rgb(192,192,192)
UseFont "Arial",14,0,1,0,0
Drawtext 10,360,"BEACHTE : Die errechneten Werte hängen von der Auflösung und der Papiersorte bzw. Papiergrösse ab, "
Drawtext 10,380,"die in der Druckereinstellung vorgenommen wurde !"
EndProc
SetTruecolor 1
cls rgb(192,192,192)
Textcolor rgb(0,0,0),rgb(192,192,192)
UseFont "Arial",18,0,1,0,1
UseCursor 2
Drawtext 10,410,"Ermittle Werte für den Standard-Drucker"
GetPrinterDC
Werte_ermitteln
Rectangle 0,8-630,356
Ausgabe
UseFont "Arial",18,0,1,0,1
Textcolor rgb(255,0,0),rgb(192,192,192)
Drawtext 10,410,"Werte für den Standard-Drucker ermittelt"
UseCursor 0
waitinput
@DeleteDC(PDC&)'Printer-DC freigeben
end
|
| | | | |
| | Andreas Miethe
| Kleinkram da geht noch viel mehr
Const.ph KompilierenMarkierenSeparieren Winspool1.inc KompilierenMarkierenSeparieren $H const.ph
'
'Strukturen
Struct DEVMODE = DeviceName$(31),dmSpecVersion%,dmDriverVersion%,\
dmSize%,dmDriverExtra%,dmFields&,dmOrientation%,\
dmPaperSize%,dmPaperLength%,dmPaperWidth%,dmScale%,\
dmCopies%,dmDefaultSource%,dmPrintQuality%,dmColor%,\
dmDuplex%,dmYResolution%,dmTTOption%,dmCollate%,\
dmFormName#(4),dmUnusedPadding%,dmBitsPerPel%,\
dmPelsWidth&,dmPelsHeight&,dmDisplayFlags&,\
dmDisplayFrequency&,ExtraData#(2000)
Struct Doc_Info1= Docname#(4),OutFile#(4),Datatype#(4)
Struct Size = Weite&,Hoehe&
'
'Definitionen
DEF GetNDP_STDPrinter(1) Substr$(ReadIni$("WIN.INI","Windows","Device"),@&(1),",")
DEF @GetSysColor(1) !"USER32","GetSysColor"
DEF DeviceCaps(5) ! "WINSPOOL.DRV","DeviceCapabilitiesA"
DEF OpenPrinter(3) !"WINSPOOL.DRV","OpenPrinterA"
DEF ClosePrinter(1) !"WINSPOOL.DRV","ClosePrinter"
DEF DocumentProperties(6) ! "WINSPOOL.DRV","DocumentPropertiesA"
DEF PrinterProperties(2) ! "WINSPOOL.DRV","PrinterProperties"
DEF SDP(2) ! "GDI32","StartDocA"
DEF EDP(1) ! "GDI32","EndDoc"
DEF SPP(1) ! "GDI32","StartPage"
DEF EPP(1) ! "GDI32","EndPage"
DEF LoadImage(6) !"user32","LoadImageA"
DEF CreateCompatibleDC(1) !"gdi32","CreateCompatibleDC"
DEF SelectObject(2) !"gdi32","SelectObject"
DEF BitBlt(9) !"gdi32","BitBlt"
DEF DeleteObject(1) !"gdi32","DeleteObject"
Def GDIDeviceCaps(2) ! "GDI32","GetDeviceCaps"
DEf LockWindowUpdate(1) ! "USER32","LockWindowUpdate"
DEF GetWindowLong(2) ! "USER32","GetWindowLongA"
DEF SetWindowLong(3) ! "USER32","SetWindowLongA"
DEF GetPrivateProfileSection(4) ! "KERNEL32","GetPrivateProfileSectionA"
DEf CreateDC(4) ! "GDI32","CreateDCA"
DEf DeleteDC(1) ! "GDI32","DeleteDC"
DEf TextOut(5) ! "gdi32","TextOutA"
DEf ExtTextOut(8) ! "gdi32","ExtTextOutA"
DEf GetTextExtentPoint32(4) ! "GDI32","GetTextExtentPoint32A"
DEf SetTextAlign(2) ! "GDI32","SetTextAlign"
DEf SetRect(5) ! "USER32","SetRect"
DEf SetBKMode(2) ! "GDI32","SetBkMode"
'Def DeleteObject(1) ! "GDI32","DeleteObject","%","%"
'Definitionen von Thomas Hoelzer
Def GetStockObject(1) !"GDI32","GetStockObject"
Def SetDefaultGUIFont(1) SendMessage(&(1),$30,Val(GetStockObject($11)),1)
'
'Deklarationen
Declare Printer#,Port#,Driver#,DevmodeInput#,Devmodeoutput#,OutPut#,Selstr#
Declare DocInfo1#
Declare Returnbuffer#
Declare DCArray&,DCSize&,DCExtra&,DCDuplex&,DCCopies&
Declare DCTrueType&,DCBins&,DCPapers&,DCOrientation&
Declare DCBinNames&,DCPaperNames&,DC_DATATYPE_PRODUCED&,DC_FILEDEPENDENCIES&
Declare DC_ENUMRESOLUTIONS&,DC_ENUMRESOLUTIONS1&
Declare DCPapersArray&
Declare DCPaperNamesArray&
Declare MyPrinter&,PrinterFont&
Declare Size#
'Funktionen
PROC TEXTHOEHE
Parameters DC&
Declare t$,w&
Dim size#,Size
T$ = "A"
GetTextExtentPoint32(DC&,addr(t$),@Len(T$),size#)
W& = size#.hoehe&
Dispose Size#
Return w&
ENDPROC
'
PROC TEXTWEITE
Parameters DC&,T$
Declare t$,w&
Dim size#,Size
GetTextExtentPoint32(DC&,addr(t$),@Len(T$),size#)
W& = size#.Weite&
Dispose Size#
Return w&
ENDPROC
'
Proc Printer_Error
'Fehlermeldung ausgeben
Parameters Errnum%,D$
Case Errnum% = 1 : @Messagebox("Kein Standard-Drucker im System installiert","Fehler 1",16)
Case Errnum% = 2 : @Messagebox("Kein Drucker ausgewählt !","Fehler 2",16)
EndProc
Proc GetPrinterParameter
'DC-Infos's holen
'Parameter Listboxhandle
Parameters LB&
Declare PName$,PDriver$,PPort$,PDC&
Declare APX!,APY!,PB!,PH!,POX!,POY!,DPIX!,DPIY!,PBMM!,PHMM!,RMM!
Declare PMAX!,PMAY!,Tech&
Declare Rastercaps&,CurveCaps&,LineCaps&,Polygoncaps&,Textcaps&
Declare POR!,PUR!
Declare PLR!,PRR!
PName$ = GetNDP_STDPrinter(1)
PDriver$ = GetNDP_STDPrinter(3)+".drv"
PPort$ = GetNDP_STDPrinter(2)
Let PDC& = CreateDC(addr(pdriver$),addr(Pname$),addr(Pport$),0)
Tech& = GDIDeviceCaps(PDC&,2)'Technologie
APX! = GDIDeviceCaps(PDC&,8)'Ausgabebreite in Pixel
APY! = GDIDeviceCaps(PDC&,10)'AusgabeHoehe in Pixel
PB! = GDIDeviceCaps(PDC&,110)'Physikalische Breite
PH! = GDIDeviceCaps(PDC&,111)'Physikalische Hoehe
POX! = GDIDeviceCaps(PDC&,112)'Offset X
POY! = GDIDeviceCaps(PDC&,113)'Offset Y
DPIX! = GDIDeviceCaps(PDC&,88)'DPI X
DPIY! = GDIDeviceCaps(PDC&,90)'DPI Y
PBMM! = GDIDeviceCaps(PDC&,4)'Ausgabebreite in mm
PHMM! = GDIDeviceCaps(PDC&,6)'Ausgabehoehe in mm
Rastercaps& = GDIDeviceCaps(PDC&,38)'Rastercaps
Curvecaps& = GDIDeviceCaps(PDC&,28)'Curvecaps
Linecaps& = GDIDeviceCaps(PDC&,20)'Linecaps
Polygoncaps& = GDIDeviceCaps(PDC&,32)'Polygoncaps
Textcaps& = GDIDeviceCaps(PDC&,34)'Textcaps
@addstring(LB&,"_____________________________")
@addstring(LB&,"Drucker-Technologie")
Case Tech& = 0 : @addstring(LB&," - Vector plotter")
Case Tech& = 1 : @addstring(LB&," - Raster display")
Case Tech& = 2 : @addstring(LB&," - Raster printer")
Case Tech& = 3 : @addstring(LB&," - Raster camera")
Case Tech& = 4 : @addstring(LB&," - Character stream")
Case Tech& = 5 : @addstring(LB&," - Metafile")
Case Tech& = 6 : @addstring(LB&," - Display file")
@addstring(LB&,"_____________________________")
@addstring(LB&,"Physikalische Druckerwerte : ")
@addstring(LB&,"Ausgabebreite in Pixel : "+str$(APX!))
@addstring(LB&,"Ausgabehöhe in Pixel : "+str$(APY!))
@addstring(LB&,"Physikalische Breite in Pixel : "+str$(PB!))
@addstring(LB&,"Physikalische Höhe in Pixel : "+str$(PH!))
@addstring(LB&,"Physikalischer Offset X : "+str$(POX!))
@addstring(LB&,"Physikalischer Offset Y : "+str$(POY!))
@addstring(LB&,"Aufloesung Breite (DPI) : "+str$(DPIX!))
@addstring(LB&,"Aufloesung Höhe (DPI) : "+str$(DPIY!))
@addstring(LB&,"Ausgabebreite in mm : "+str$(PBMM!*10))
@addstring(LB&,"Ausgabehöhe in mm : "+str$(PHMM!*10))
@addstring(LB&,"_____________________________")
@addstring(LB&,"Physikalische Blatt-Grenzen :")
@addstring(LB&,"Linker Rand in Pixel : "+STR$(POX!))
@addstring(LB&,"Rechter Rand in Pixel : "+STR$(((PB!-APX!)-POX!)))
@addstring(LB&,"Oberer Rand in Pixel : "+STR$(POY!))
@addstring(LB&,"Unterer Rand in Pixel : "+STR$(((PH!-APY!)-POY!)))
Decimals 1
PLR!=ROUND(((PBMM!/APX!)*POX!),1)
PRR!=ROUND(((PBMM!/APX!)*((PB!-APX!)-POX!)),1)
POR!=ROUND(((PHMM!/APY!)*POY!),1)
PUR!=ROUND(((PHMM!/APY!)*((PH!-APY!)-POY!)),1)
@addstring(LB&,"Linker Rand in mm : "+STR$(PLR!))
@addstring(LB&,"Rechter Rand in mm : "+STR$(PRR!))
@addstring(LB&,"Oberer Rand in mm : "+STR$(POR!))
@addstring(LB&,"Unterer Rand in mm : "+STR$(PUR!))
Decimals 0
@addstring(LB&,"Blattgrösse X in mm : "+STR$((((PBMM!+PLR!)+PRR!)*10)))
@addstring(LB&,"Blattgrösse Y in mm : "+STR$((((PHMM!+POR!)+PUR!)*10)))
@addstring(LB&,"_____________________________")
@addstring(LB&,"RasterCap - Flags :")
@addstring(LB&,"Flags : "+Hex$(Rastercaps&))
Case (Rastercaps& & 1) : @addstring(LB&," - Bitblt")
Case (Rastercaps& & 2) : @addstring(LB&," - Banding")
Case (Rastercaps& & 4) : @addstring(LB&," - Skalierung")
Case (Rastercaps& & 8) : @addstring(LB&," - Bitmaps > 64K")
Case (Rastercaps& & 16) : @addstring(LB&," - Windows 2.0 Features")
Case (Rastercaps& & 32) : @addstring(LB&," - GDI20_STATE")
Case (Rastercaps& & 64) : @addstring(LB&," - SAVEBITMAP")
Case (Rastercaps& & 128) : @addstring(LB&," - GetDIBits SetDIBits")
Case (Rastercaps& & 256) : @addstring(LB&," - Paletten-Spezifikation")
Case (Rastercaps& & 512) : @addstring(LB&," - SetDIBitsToDevice")
Case (Rastercaps& & 1024) : @addstring(LB&," - BIGFONT")
Case (Rastercaps& & 2048) : @addstring(LB&," - StretchBlt")
Case (Rastercaps& & 4096) : @addstring(LB&," - Floodfill")
Case (Rastercaps& & 8192) : @addstring(LB&," - StretchDIB")
Case (Rastercaps& & 16384) : @addstring(LB&," - OP_DX_OUTPUT")
Case (Rastercaps& & 32768) : @addstring(LB&," - DevBits")
@addstring(LB&,"_____________________________")
@addstring(LB&,"CurveCap - Flags :")
@addstring(LB&,"Flags : "+hex$(Curvecaps&))
Case (Curvecaps& & 2) : @addstring(LB&," - PIE")
Case (Curvecaps& & 4) : @addstring(LB&," - PREVENTFULLOPEN")
Case (Curvecaps& & 8) : @addstring(LB&," - SHOWHELP")
Case (Curvecaps& & 16) : @addstring(LB&," - WIDE")
Case (Curvecaps& & 32) : @addstring(LB&," - STYLED")
Case (Curvecaps& & 64) : @addstring(LB&," - WIDESTYLED")
Case (Curvecaps& & 128) : @addstring(LB&," - SOLIDCOLOR")
Case (Curvecaps& & 256) : @addstring(LB&," - ROUNDRECT")
@addstring(LB&,"_____________________________")
@addstring(LB&,"LineCap - Flags :")
@addstring(LB&,"Flags : "+hex$(Linecaps&))
Case (Linecaps& & 2) : @addstring(LB&," - POLYLINE")
Case (Linecaps& & 4) : @addstring(LB&," - MARKER")
Case (Linecaps& & 8) : @addstring(LB&," - POLYMARKER")
Case (Linecaps& & 16) : @addstring(LB&," - WIDE")
Case (Linecaps& & 32) : @addstring(LB&," - STYLED")
Case (Linecaps& & 64) : @addstring(LB&," - WIDESTYLED")
Case (Linecaps& & 128) : @addstring(LB&," - INTERIORS")
@addstring(LB&,"_____________________________")
@addstring(LB&,"PolygonCap - Flags :")
@addstring(LB&,"Flags : "+hex$(Polygoncaps&))
Case (Polygoncaps& & 1) : @addstring(LB&," - POLYGON")
Case (Polygoncaps& & 2) : @addstring(LB&," - RECTANGLE")
Case (Polygoncaps& & 4) : @addstring(LB&," - TRAPEZOID")
Case (Polygoncaps& & 8) : @addstring(LB&," - SCANLINE")
Case (Polygoncaps& & 16) : @addstring(LB&," - WIDE")
Case (Polygoncaps& & 32) : @addstring(LB&," - STYLED")
Case (Polygoncaps& & 64) : @addstring(LB&," - WIDESTYLED")
Case (Polygoncaps& & 128) : @addstring(LB&," - INTERIORS")
Case (Polygoncaps& & 256) : @addstring(LB&," - POLYPOLYGON")
@addstring(LB&,"_____________________________")
@addstring(LB&,"TextCap - Flags :")
@addstring(LB&,"Flags : "+hex$(Textcaps&))
Case (Textcaps& & 1) : @addstring(LB&," - OP_CHARACTER")
Case (Textcaps& & 2) : @addstring(LB&," - OP_STROKE")
Case (Textcaps& & 4) : @addstring(LB&," - CP_STROKE")
Case (Textcaps& & 8) : @addstring(LB&," - CR_90")
Case (Textcaps& & 16) : @addstring(LB&," - CR_ANY")
Case (Textcaps& & 32) : @addstring(LB&," - SF_X_YINDEP")
Case (Textcaps& & 64) : @addstring(LB&," - SA_DOUBLE")
Case (Textcaps& & 128) : @addstring(LB&," - SA_INTEGER")
Case (Textcaps& & 256) : @addstring(LB&," - SA_CONTIN")
Case (Textcaps& & 512) : @addstring(LB&," - EA_DOUBLE")
Case (Textcaps& & 1024) : @addstring(LB&," - IA_ABLE")
Case (Textcaps& & 2048) : @addstring(LB&," - UA_ABLE")
Case (Textcaps& & 4096) : @addstring(LB&," - SO_ABLE")
Case (Textcaps& & 8192) : @addstring(LB&," - RA_ABLE")
Case (Textcaps& & 16384) : @addstring(LB&," - VA_ABLE")
Case (Textcaps& & 32768) : @addstring(LB&," - RESERVED")
Case (Textcaps& & 65536) : @addstring(LB&," - SCROLLBLT")
DeleteDC(PDC&)
EndProc
Proc PrnProp
'Einrichtungs-Dialog des Druckertreibers
Declare Ret&
Dim Printer#,Len(GetNDP_STDPrinter(1))+100
String Printer#,0=GetNDP_STDPrinter(1)
If OpenPrinter(Printer#,Addr(MyPrinter&),0)<>0
Ret& = PrinterProperties(%hwnd,MyPrinter&)
ClosePrinter(MyPrinter&)
EndIf
Dispose Printer#
Return Ret&
EndProc
'
Proc DocProp
'Setzen der Druckereinrichtung
'Parameter : 1 oder 0 für Systemweit oder Programmweit
Parameters a%
Declare Ret&
Dim Printer#,Len(GetNDP_STDPrinter(1))+100
Dim DevmodeInput#,Devmode
Dim Devmodeoutput#,Devmode
string Printer#,0=GetNDP_STDPrinter(1)
If OpenPrinter(Printer#,Addr(MyPrinter&),0)<>0
Case (a%=0):Ret& = DocumentProperties(%hwnd,MyPrinter&,Printer#,DevmodeInput#,DevmodeOutput#,12)
Case (a%=1):Ret& = DocumentProperties(%hwnd,MyPrinter&,Printer#,DevmodeInput#,DevmodeOutput#,13)
ClosePrinter(MyPrinter&)
EndIf
Dispose Printer#
Dispose DevmodeInput#
Dispose Devmodeoutput#
Return Ret&
EndProc
'
Proc GetPrinterCaps
'allgemeine Druckerwerte holen
'Parameter : Listboxhandle
UseCursor 2
Parameters LB&
Declare DM$,x%,a%,ax&,ay&
Clearlist
Dim Printer#,Len(GetNDP_STDPrinter(1))+100
Dim Port#,Len(GetNDP_STDPrinter(2))+100
Dim Output#,$FFFF
string Printer#,0=GetNDP_STDPrinter(1)
string Port#,0=GetNDP_STDPrinter(2)
let DCSize& = DeviceCaps(Printer#,Port#,8,0,0)
let DCExtra& = DeviceCaps(Printer#,Port#,9,0,0)
let DCDuplex& = DeviceCaps(Printer#,Port#,7,0,0)
let DCCopies& = DeviceCaps(Printer#,Port#,18,0,0)
let DCOrientation& = DeviceCaps(Printer#,Port#,17,0,0)
let DCBins& = DeviceCaps(Printer#,Port#,6,0,0)
let DCPapers& = DeviceCaps(Printer#,Port#,2,0,0)
let DCTrueType& = DeviceCaps(Printer#,Port#,15,0,0)
Decimals 0
addstring "Devmode - Strukturgroesse = "+str$(DCSize&+DCExtra&)
Case DCDuplex& = 1:addstring "Duplex-Printer"
Casenot DCDuplex& = 1:addstring "Kein Duplex-Printer"
addstring "Maximale Anzahl der Kopien = "+str$(DCCopies&)
addstring "Rotation bei Querformat = "+(str$(DCOrientation&)+"°")
addstring "Einzugsschaechte = ",str$(DCBins&)
addstring "unterstützte Papierformate = ",str$(DCPapers&)
DC_ENUMRESOLUTIONS& = DeviceCaps(Printer#,Port#,13,0,0)
If DC_ENUMRESOLUTIONS& > -1
addstring "mögliche Auflösungen = "+str$(DC_ENUMRESOLUTIONS&)
Clear Output#
x% = 0
DC_ENUMRESOLUTIONS1& = DeviceCaps(Printer#,Port#,13,Output#,0)
Whilenot x% = DC_ENUMRESOLUTIONS&*4
Addstring Str$(Long(Output#,x%))+" X "+Str$(Long(Output#,x%+4))+" DPI"
x% = x% + 4
EndWhile
Endif
Clear Output#
let DC_DATATYPE_PRODUCED& = DeviceCaps(Printer#,Port#,21,Output#,0)
Case DC_DATATYPE_PRODUCED& = -1: addstring "Druckmodus = RAW"
Clear Output#
let DC_FILEDEPENDENCIES& = DeviceCaps(Printer#,Port#,21,Output#,0)
x% = 0
a% = 0
If DC_FILEDEPENDENCIES& <> -1
Whilenot x% = DC_FILEDEPENDENCIES&
DM$ = string$(Output#,a%)
addstring "Druckmodus = "+DM$
inc x%
a% = a% + 64
Endwhile
Endif
Case DCTrueType& = 1 : addstring "TrueType-Optionen = Bitmap"
Case DCTrueType& = 2 : addstring "TrueType-Optionen = Download"
Case DCTrueType& = 8 : addstring "TrueType-Optionen = Download Outline"
Case DCTrueType& = 3 : addstring "TrueType-Optionen = Substitute"
Case DCTrueType& = 6 : addstring "TrueType-Optionen = Bitmap,Download,Substitute"
Case DCTrueType& = 14 : addstring "TrueType-Optionen = Bitmap,Download,Download Outline,Substitute"
SendMessage(LB&,$0184,0,0)
Movelisttolist (lb&)
Dispose Printer#
Dispose Port#
Dispose Output#
EndProc
'
Proc PrinterBins
'Namen der Einzugsschächte holen
'Parameter : Listboxhandle
UseCursor 2
Parameters LB&
Clearlist
Declare x%
Dim Printer#,Len(GetNDP_STDPrinter(1))+100
Dim Port#,Len(GetNDP_STDPrinter(2))+100
Dim Output#,$ffff
string Printer#,0=GetNDP_STDPrinter(1)
string Port#,0=GetNDP_STDPrinter(2)
DeviceCaps(Printer#,Port#,12,Output#,0)' DCBinNames
Whilenot x% = (DCBins&*24)
addstring String$(Output#,x%)
x% = x%+24
EndWhile
SendMessage(LB&,$0184,0,0)
Movelisttolist (LB&)
Dispose Printer#
Dispose Port#
Dispose Output#
EndProc
'
Proc PaperNames
'Namen der unterstützten Papierformate holen
'Parameter : Listboxhandle
UseCursor 2
Parameters LB&
Clearlist
Declare x%
Dim Printer#,Len(GetNDP_STDPrinter(1))+100
Dim Port#,Len(GetNDP_STDPrinter(2))+100
Dim Output#,$ffff
string Printer#,0=GetNDP_STDPrinter(1)
string Port#,0=GetNDP_STDPrinter(2)
DeviceCaps(Printer#,Port#,16,Output#,0)' DCPaperNames
Whilenot x% = (DCPapers&*64)
addstring String$(Output#,x%)
x% = x%+64
EndWhile
SendMessage(LB&,$0184,0,0)
Movelisttolist (LB&)
Dispose Printer#
Dispose Port#
Dispose Output#
EndProc
'
Proc PaperFlags
'Bezeichner für Papierformate holen
'Parameter : Listboxhandle
UseCursor 2
Parameters LB&
Clearlist
Declare x%
Dim Printer#,Len(GetNDP_STDPrinter(1))+100
Dim Port#,Len(GetNDP_STDPrinter(2))+100
Dim Output#,$ffff
string Printer#,0=GetNDP_STDPrinter(1)
string Port#,0=GetNDP_STDPrinter(2)
DeviceCaps(Printer#,Port#,2,Output#,0)' DCPapers
Whilenot x% = (DCPapers&*2)
addstring str$(word(Output#,x%))
x% = x%+2
EndWhile
SendMessage(LB3&,$0184,0,0)
Movelisttolist (LB3&)
Dispose Printer#
Dispose Port#
Dispose Output#
EndProc
'
Proc Akt_Printer_Einstellungen
'aktuelle Druckereinstellung holen
'Parameter : Listboxhandle
UseCursor 2
Parameters LB&,LB2&,LB3&
Declare Nr&,ST$
Clearlist
Dim Printer#,Len(GetNDP_STDPrinter(1))+100
Dim DevmodeInput#,Devmode
Dim Devmodeoutput#,Devmode
Dim Selstr#,200
string Printer#,0=GetNDP_STDPrinter(1)
If OpenPrinter(Printer#,Addr(MyPrinter&),0)<>0
DocumentProperties(%hwnd,MyPrinter&,Printer#,DevmodeInput#,DevmodeOutput#,2)
ClosePrinter(MyPrinter&)
EndIf
Addstring "Druckername : "+DevmodeInput#.Devicename$
Addstring "Treiber-Version : "+Str$(DevmodeInput#.dmDriverVersion%)
Addstring "Devmode-Size : "+Str$(DevmodeInput#.dmSize%)
Addstring "Treiber-Extra-Bytes : "+Str$(DevmodeInput#.dmDriverExtra%)
Addstring "Devmode-Fields : "+Hex$(DevmodeInput#.dmFields&)
Case (DevmodeInput#.dmFields& & 1) : Addstring " - DM_ORIENTATION"
Case (DevmodeInput#.dmFields& & 2) : Addstring " - DM_OUT_BUFFER"
Case (DevmodeInput#.dmFields& & 4) : Addstring " - DM_PAPERLENGTH"
Case (DevmodeInput#.dmFields& & 8) : Addstring " - DM_PAPERWIDTH"
Case (DevmodeInput#.dmFields& & 16) : Addstring " - DM_SCALE"
Case (DevmodeInput#.dmFields& & 256) : Addstring " - DM_COPIES"
Case (DevmodeInput#.dmFields& & 512) : Addstring " - DM_DEFAULTSOURCE"
Case (DevmodeInput#.dmFields& & 1024) : Addstring " - DM_PRINTQUALITY"
Case (DevmodeInput#.dmFields& & 2048) : Addstring " - DM_COLOR"
Case (DevmodeInput#.dmFields& & 4096) : Addstring " - DM_DUPLEX"
Case (DevmodeInput#.dmFields& & 8192) : Addstring " - DM_YRESOLUTION"
Case (DevmodeInput#.dmFields& & 32768) : Addstring " - DM_COLLATE"
Case (DevmodeInput#.dmFields& & 65536) : Addstring " - DM_FORMNAME"
Case (DevmodeInput#.dmFields& & 131072) : Addstring " - DM_LOGPIXELS"
Case (DevmodeInput#.dmFields& & 262144) : Addstring " - DM_BITSPERPEL"
Case (DevmodeInput#.dmFields& & 524288) : Addstring " - DM_PELSWIDTH"
Case (DevmodeInput#.dmFields& & 1048576) : Addstring " - DM_PELSHEIGHT"
Case (DevmodeInput#.dmFields& & 2097152) : Addstring " - DM_DISPLAYFLAGS"
Case (DevmodeInput#.dmFields& & 4194304) : Addstring " - DM_DISPLAYFREQUENCY"
Case (DevmodeInput#.dmFields& & 33554432) : Addstring " - DM_ICMMETHOD"
Case (DevmodeInput#.dmFields& & 67108864) : Addstring " - DM_ICMINTENT"
Case (DevmodeInput#.dmFields& & 134217728) : Addstring " - DM_MEDIATYPE"
Case (DevmodeInput#.dmFields& & 268435456) : Addstring " - DM_DITHERTYPE"
Case DevmodeInput#.dmOrientation%=~DMORIENT_LANDSCAPE:Addstring "Orientierung : Landscape"
Case DevmodeInput#.dmOrientation%=~DMORIENT_PORTRAIT:Addstring "Orientierung : Portrait"
St$= str$(DevmodeInput#.dmPaperSize%)
Nr& = Sendmessage(LB3&,$018F,-1,addr(st$))
Sendmessage(LB2&,$0189,nr&,Selstr#)
Addstring "Papierformat : "+string$(Selstr#,0)
Addstring "Papierlänge : "+str$(DevmodeInput#.dmPaperLength%)+" mm"
Addstring "Papierbreite : "+str$(DevmodeInput#.dmPaperWidth%)+" mm"
Addstring "Skalierung : "+str$(DevmodeInput#.dmScale%)+" %"
Addstring "Kopien : "+str$(DevmodeInput#.dmCopies%)
St$= str$(DevmodeInput#.dmDefaultSource%)
Nr& = Sendmessage(LB3&,$018F,-1,addr(st$))
Sendmessage(LB2&,$0189,nr&,Selstr#)
Addstring "Default-Source : "+String$(Selstr#,0)
Case (word(DevmodeInput#,58)=65535):Addstring "Druckqualität : Draft"
Case (word(DevmodeInput#,58)=65534):Addstring "Druckqualität : Low"
Case (word(DevmodeInput#,58)=65533):Addstring "Druckqualität : Medium"
Case (word(DevmodeInput#,58)=65532):Addstring "Druckqualität : High"
Case (word(DevmodeInput#,58)>65535) Or (word(DevmodeInput#,58)<65532):\
addstring "Druckqualität : "+str$(word(DevmodeInput#,58))+" DPI"
Case (DevmodeInput#.dmColor%=~DMCOLOR_COLOR):Addstring "Farbdruck : Farbe"
Case (DevmodeInput#.dmColor%=~DMCOLOR_MONOCHROME):Addstring "Farbdruck : Graustufen"
Case (DevmodeInput#.dmDuplex%=~DMDUP_SIMPLEX):Addstring "Duplex : 1-seitig"
Case (DevmodeInput#.dmDuplex%=~DMDUP_VERTICAL):Addstring "Duplex : 2-seitig-vertikal"
Case (DevmodeInput#.dmDuplex%=~DMDUP_HORIZONTAL):Addstring "Duplex : 2-seitig-horizontal"
Addstring "Y-Auflösung : "+str$(DevmodeInput#.dmYResolution%)
Case (DevmodeInput#.dmTTOption%=~DMTT_BITMAP):Addstring "Truetype als : Bitmap"
Case (DevmodeInput#.dmTTOption%=~DMTT_DOWNLOAD):Addstring "Truetype als : Download"
Case (DevmodeInput#.dmTTOption%=~DMTT_SUBDEV):Addstring "Truetype als : Ersatz"
Case (DevmodeInput#.dmTTOption%=~DMTT_DOWNLOAD_OUTLINE):Addstring "Truetype als : Download-Outline"
Case (DevmodeInput#.dmCollate%=~DMCOLLATE_FALSE):Addstring "Collate : Nein"
Case (DevmodeInput#.dmCollate%=~DMCOLLATE_TRUE):Addstring "Collate : Ja"
Case (word(DevmodeInput#,132)=~DMMEDIA_STANDARD):Addstring "Druckermedium : Normalpapier"
Case (word(DevmodeInput#,132)=~DMMEDIA_GLOSSY):Addstring "Druckermedium : Glossy"
Case (word(DevmodeInput#,132)=~DMMEDIA_TRANSPARENCY):Addstring "Druckermedium : Transparent"
Case (word(DevmodeInput#,132)=~DMMEDIA_USER):Addstring "Druckermedium : Benutzerdefiniert"
SendMessage(LB&,$0184,0,0)
Movelisttolist (LB&)
Dispose DevmodeInput#
Dispose DevmodeOutput#
Dispose Printer#
Dispose Selstr#
EndProc
'
Proc GetPrinters
'Drucker im System ermitteln
'Parameter : Listboxhandle
Parameters LB&
Clearlist
Declare Section_name$,ReturnSize&,IniFile$,Returnname$,x%
Declare PName$,PDriver$,PPort$
Section_name$ = "DEVICES"
IniFile$ = "Win.ini"
Returnsize& = 32767
Dim ReturnBuffer#,Returnsize&
GetPrivateProfileSection(ADDR(Section_name$),ReturnBuffer#,ReturnSize&,ADDR(IniFile$))
Whilenot x% = Returnsize&
Returnname$ = String$(ReturnBuffer#,x%)
Case returnname$ = "": Break
Pname$ = Substr$(Returnname$,1,"=")'Name
PDriver$ = Substr$(Substr$(Returnname$,1,","),2,"=")'Treiber
PPort$ = Substr$(Substr$(Returnname$,2,","),1,"=")'Port
AddString PName$+","+PDriver$+","+PPort$
X% = X% + Len(Returnname$) +1
Endwhile
SendMessage(LB&,$0184,0,0)
Movelisttolist (LB&)
Dispose Returnbuffer#
EndProc
'
Proc ChangeStandardPrinter
'Standard-Drucker wechseln
Parameters F$
Declare IniFile$
IniFile$ = "Win.ini"
WRITEINI "Win.Ini","Windows","Device"=F$
SendMessage($FFFF,$001A,0,ADDR(IniFile$))'Win-Ini-Update
EndProc
Programm KompilierenMarkierenSeparieren'#########################################
'Drucker-Einstellungen holen und setzen
'ab Win 9.X und Profan 7.X
'Andreas Miethe * Dezember 2000
'#########################################
'
'
$I Winspool1.inc
'
Declare TTT&,LB&,LB1&,LB2&,LB3&,LB4&,LB5&
Declare Ende%,GetP&,SetP&,Config&,Config1&,GoOut&
Declare Picture$
'
settruecolor 1
WindowTitle "Druckereinstellungen......"
Window %maxx+1,0-640,480
cls @GetSysColor(15)
UseIcon "DRUCKER"
Usefont "MS Sans Serif",14,0,0,0,0
SetDialogfont 1
Proc Fensteraufbau
TTT& = Createtext(%hwnd,"",12,0,600,14)
Createtext(%hwnd,"Allgemeine Infos",12,14,300,24)
Let LB& = CreateListbox(%hwnd,"",0,0,0,0)
SetDefaultGUIFont(LB&)
Createtext(%hwnd,"Druckerschächte",12,114,300,14)
Let LB1& = CreateListbox(%hwnd,"",0,0,0,0)
SetDefaultGUIFont(LB1&)
Createtext(%hwnd,"unterstützte Papierformate",12,214,300,14)
Let LB2& = CreateListbox(%hwnd,"",0,0,0,0)
SetDefaultGUIFont(LB2&)
Createtext(%hwnd,"Installierte Drucker",12,315,300,14)
Let LB5& = CreateListbox(%hwnd,"",0,0,0,0)
SetDefaultGUIFont(LB5&)
Createtext(%hwnd,"Format-NR.",322,214,90,14)
Let LB3& = CreateListbox(%hwnd,"",0,0,0,0)
SetDefaultGUIFont(LB3&)
Createtext(%hwnd,"aktuelle Einstellungen, Werte und Möglichkeiten",322,14,320,14)
Let LB4& = CreateListbox(%hwnd,"",0,0,0,0)
SetDefaultGUIFont(LB3&)
Let SetP& = CreateButton(%hwnd,"Standard-Drucker wechseln",320,405,220,20)
SetDefaultGUIFont(SetP&)
Let Config& = CreateButton(%hwnd,"Drucker einrichten",320,355,220,20)
SetDefaultGUIFont(Config&)
Let Config1& = CreateButton(%hwnd,"Drucker - Eigenschaften",320,380,220,20)
SetDefaultGUIFont(Config&)
Let GoOut& = CreateButton(%hwnd,"Ende",440,260,80,20)
SetDefaultGUIFont(GoOut&)
@Control("Static","Drucker",$50000003,580,390,0,0,%hwnd,0,%Hinstance,0)
Settext TTT&,"Drucker : "+GetNDP_STDPrinter(1)+" an : "+GetNDP_STDPrinter(3)
SetWindowlong(LB&,-16,GetWindowlong(LB1&,-16) | ,$50200000)
SetWindowlong(LB1&,-16,GetWindowlong(LB1&,-16) | $50200000)
SetWindowlong(LB2&,-16,GetWindowlong(LB1&,-16) | $50200000)
SetWindowlong(LB3&,-16,GetWindowlong(LB1&,-16) | $50200000)
SetWindowlong(LB4&,-16,GetWindowlong(LB1&,-16) | $50200000)
SetWindowlong(LB5&,-16,GetWindowlong(LB1&,-16) | ,$50200000)
Setwindowpos LB& = 10,30-300,80
Setwindowpos LB1& = 10,130-300,80
Setwindowpos LB2& = 10,230-300,80
Setwindowpos LB3& = 320,230-100,80
Setwindowpos LB4& = 320,30-300,180
Setwindowpos LB5& = 10,335-300,90
EndProc
Proc GetInfo
Declare msg&,msgt&
If GetNDP_STDPrinter(1) <> ""
UseCursor 2
LockWindowUpdate(%hwnd)
msg& = CreateDialog(%hwnd,"Moment bitte...",(%maxx+1),0,0,0)
msgt& = Createtext(msg&,"ermittle Werte..........",20,2,180,20)
Setwindowlong(msg&,-16,$50C00000)
Setwindowlong(msg&,-20,$50000280)
Setwindowpos msg& = (Width(%Desktop)/2-100) ,(Height(%desktop)/2-22) - 200,45
Settext TTT&,"Drucker : "+GetNDP_STDPrinter(1)+" an : "+GetNDP_STDPrinter(3)
GetPrinters LB5&
GetPrinterCaps LB&
PrinterBins LB1&
PaperNames LB2&
PaperFlags LB3&
Akt_Printer_Einstellungen LB4&,LB2&,LB3&
GetPrinterParameter LB4&
Destroywindow(msg&)
LockWindowUpdate(0)
UseCursor 0
else
Printer_Error 1
Endif
EndProc
Fensteraufbau
setwindowpos %hwnd = (Width(%Desktop)/2-320) ,(Height(%desktop)/2-240) - 640,480
GetPrinters LB5&
GetInfo
SetFocus(%hwnd)
Whilenot ende%
waitinput
If GetFocus(GetP&)
PrintPrinter LB4&
setFocus(%hwnd)
Elseif GetFocus(SetP&)
If @getCursel(LB5&) > -1
ChangeStandardPrinter Getstring$(LB5&,@GetCursel(LB5&))
Settext TTT&,"Drucker : "+GetNDP_STDPrinter(1)+" an : "+GetNDP_STDPrinter(3)
GetInfo
setFocus(%hwnd)
else
Printer_Error 2
Endif
Elseif GetFocus(Config&)
If GetNDP_STDPrinter(1) <> ""
DocProp 1
Case @&(0) = 1: GetInfo
setFocus(%hwnd)
else
Printer_Error 1
Endif
Elseif GetFocus(Config1&)
If GetNDP_STDPrinter(1) <> ""
PrnProp
Case @&(0) = 1: GetInfo
setFocus(%hwnd)
else
Printer_Error 1
Endif
Elseif GetFocus(GoOut&)
Let Ende% = 1
Endif
EndWhile
End
|
| | | Gruss Andreas ________ ________ ________ ________ _ Profan 3.3 - XProfanX2 Win 95,98,ME,2000,XP,Vista - Win 7 32 / 64 Bit ASUS X93S - Intel Core I7-NVIDIA GForce 540M 8GB Arbeitsspeicher Homepage : [...] | 17.12.2010 ▲ |
| |
| | | Gewaltig ^^ !
Ein kleiner Bug aber lässts abstürzen - in der WinSpool1.inc Funktion Akt_Printer_Einstellungen ganz unten muss ich Dispose DevmodeOutput# ausklammern da ich sonst einen Absturz erhalte: KompilierenMarkierenSeparieren (habe mich mit MessageBoxen hingekämpft... ^^)
Ich sehe auf Anhieb nicht warum das der Fall ist - ansonsten läuft es tadellos durch und zeigt all diese lecker Eigenschaften...:
|
| | | | |
|
Zum QuelltextThemenoptionen | 6.355 Betrachtungen |
ThemeninformationenDieses Thema hat 2 Teilnehmer: |