Platforms to show: All Mac Windows Linux Cross-Platform

/Win/Printing/Windows Printer


Required plugins for this example: MBS Win Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Printing/Windows Printer

This example is the version from Sun, 17th Mar 2012.

Project "Windows Printer.xojo_binary_project"
FileTypes
Filetype text
Filetype Alle
End FileTypes
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim w as WindowsAddPrintJobMBS dim size as integer w=new WindowsAddPrintJobMBS if not w.OpenPrinter(PopupMenu1.Text) then ListBox1.AddRow( "OpenPrinter failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return else ListBox1.AddRow( "Printer: "+hex(w.PrinterHandle)) ListBox1.ScrollPosition = ListBox1.ListCount - 1 end if if w.AddJob then ListBox1.AddRow( "JobID: "+str(w.JobID)) ListBox1.AddRow( "JobPath: "+w.JobPath) ListBox1.ScrollPosition = ListBox1.ListCount - 1 else ListBox1.AddRow( "AddJob failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if size=w.WriteJob(EditField1.text) ListBox1.AddRow( "Write: "+str(size)) ListBox1.ScrollPosition = ListBox1.ListCount - 1 if not w.ScheduleJob then ListBox1.AddRow( "ScheduleJob failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if w=nil ListBox1.AddRow( "finished." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 End EventHandler
End Control
Control EditField1 Inherits TextArea
ControlInstance EditField1 Inherits TextArea
End Control
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim w as WindowsAddPrintJobMBS dim size as integer dim f As FolderItem dim binIn As BinaryStream f=GetOpenFolderItem("Alle" ) if f=NIL or f.Exists=False then Return end if w=new WindowsAddPrintJobMBS if not w.OpenPrinter(PopupMenu1.Text) then ListBox1.AddRow( "OpenPrinter failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return else ListBox1.AddRow( "Printer: "+hex(w.PrinterHandle)) ListBox1.ScrollPosition = ListBox1.ListCount - 1 end if if w.AddJob then ListBox1.AddRow( "JobID: "+str(w.JobID)) ListBox1.AddRow( "JobPath: "+w.JobPath) ListBox1.ScrollPosition = ListBox1.ListCount - 1 else ListBox1.AddRow( "AddJob failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if binIn=f.OpenAsBinaryFile(False) size=w.WriteJob(binIn.Read(binIn.Length)) ListBox1.AddRow( "Write: "+str(size)) ListBox1.ScrollPosition = ListBox1.ListCount - 1 binIn.Close binIn=NIL if not w.ScheduleJob then ListBox1.AddRow( "ScheduleJob failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if w=nil ListBox1.AddRow( "finished." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 End EventHandler
End Control
Control PopupMenu1 Inherits PopupMenu
ControlInstance PopupMenu1 Inherits PopupMenu
EventHandler Sub Open() if targetWin32 then // add printer names ot the popupmenu for each w as WindowsPrinterInfoMBS in WindowsPrinterInfoMBS.LocalPrinters me.addRow(w.PrinterName) next // select first me.listIndex=0 end if End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() // dim f As FolderItem = GetOpenFolderItem( "Alle" ) if f = NIL or f.Exists = False then Return end if // dim w As New WindowsAddPrintJobMBS // if not w.OpenPrinter( PopupMenu1.Text ) then ListBox1.AddRow( "OpenPrinter failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return else ListBox1.AddRow( "Printer: " + Hex( w.PrinterHandle ) ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 end if // if Not w.StartDocPrinter( f.Name, "", w.kDataFormatRAW ) then ListBox1.AddRow( "StartDocPrinter failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if if Not w.StartPagePrinter then ListBox1.AddRow( "StartPagePrinter failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if dim binIn As BinaryStream = f.OpenAsBinaryFile(false) // BinaryStream.Open( f ) dim size As Integer = w.WritePrinter( binIn.Read( binIn.Length ) ) ListBox1.AddRow( "Write: " + Str( size ) ) + " kb" ListBox1.ScrollPosition = ListBox1.ListCount - 1 binIn.Close binIn=NIL if not w.EndPagePrinter then ListBox1.AddRow( "EndPagePrinter failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if if not w.EndDocPrinter then ListBox1.AddRow( "EndDocPrinter failed." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 Return end if w = nil ListBox1.AddRow( "finished." ) ListBox1.ScrollPosition = ListBox1.ListCount - 1 End EventHandler
End Control
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Win Plugin.


The biggest plugin in space...