You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/Windows Switch Printers for printing
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action()
dim LocalPrinters() as WindowsPrinterInfoMBS = WindowsPrinterInfoMBS.LocalPrinters
dim DefaultPrinter as string = WindowsPrinterMBS.GetDefaultPrinter
for i as integer = 1 to 2
for each p as WindowsPrinterInfoMBS in LocalPrinters
call WindowsPrinterMBS.SetDefaultPrinter(p.PrinterName)
dim g as Graphics = OpenPrinter
g.DrawString "Printing page "+str(i)+" on "+p.PrinterName, 100, 100
g = nil // close
next
next
call WindowsPrinterMBS.SetDefaultPrinter(DefaultPrinter)
End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open()
dim LocalPrinters() as WindowsPrinterInfoMBS = WindowsPrinterInfoMBS.LocalPrinters
for each p as WindowsPrinterInfoMBS in LocalPrinters
list.AddRow p.PrinterName, p.PortName, p.ServerName
next
End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar