Restored from previous forum. Originally posted by gnozal.
I'd like more printer functions :
Some ideas :
1. Start to print _without_ a PrinterRequester waiting for an user input.
If PrintBegin(PrinterName$) ; if PrinterName$ = "" then default printer
... printing stuff
EndIf
2. Get the name of windows default printer
PrinterName$ = GetDefaultPrinter()
3. And of all defined printers
If ExaminePrinters()
While NextPrinter()
PrinterName$ = GetPrinterName()
Wend
EndIf
More Printer functions please [:)]
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Try this:
Code: Select all
; ------------------------------------------------
; Print sideways (Landscape mode)
; Author unknown (Kanati??) - from the German forum
; ------------------------------------------------
;What to print
Printoutt.s = "Kanati is a nice guy and such a pleasure to talk to."
x.l = Len(Printoutt)
;Standard printer information
STDPrinterName$ = Space(260)
GetPrivateProfileString_("WINDOWS","DEVICE","", @STDPrintername$, 260, "Win.Ini")
STDPrintername$ = StringField(STDPrintername$, 1,",")
PrinterHandle.l = 0
OpenPrinter_(StdPrintername$,@PrinterHandle.l,0)
;MessageRequester("",Str(PrinterHandle),0)
Dim DevIn.DEVMODE(0)
Dim DevOut.DEVMODE(0)
DocumentProperties_(0,Printerhandle,StdPrintername$,DevIn(0),DevOut(0),#DM_OUT_BUFFER|#DM_IN_BUFFER)
ClosePrinter_(PrinterHandle)
If DevIn(0)\dmOrientation = 1
MessageRequester("Printer Orientation","Landscape Mode",0)
ElseIf DevIn(0)\dmOrientation = 2
MessageRequester("Printer Orientation","Portrait Mode",0)
EndIf
DevIn(0)\dmOrientation = 2; Set to Landscape mode and print results
PrinterDC.l = CreateDC_("WINSPOOL",StdPrintername$,0,DevIn(0))
DocInf.DOCINFO
DocInf\cbSize = SizeOf(DOCINFO)
DocInf\lpszDocName = @"Mein Dok"
DocInf\lpszOutput = #NULL
If StartDoc_(PrinterDC,@DocInf) > 0
If StartPage_(PrinterDC) > 0
TextOut_(PrinterDC,60,70,@Printoutt,x)
EndPage_(PrinterDC)
EndDoc_(PrinterDC)
EndIf
EndIf