Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/Win/Printing/WinPrint
Function:
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/WinPrint
This example is the version from Sun, 17th Mar 2012.
Project "WinPrint.rbp"
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 // list all printer names in 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
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

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins