Platforms to show: All Mac Windows Linux Cross-Platform
/MacCG/Carbon Print Manager/Change current printer
Required plugins for this example: MBS MacCG Plugin, MBS MacCF Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/Carbon Print Manager/Change current printer
This example is the version from Wed, 15th May 2012.
Project "Change current printer.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control ListBox1 Inherits ListBox
ControlInstance ListBox1 Inherits ListBox
EventHandler Sub Change()
if me.listindex = -1 then
PushButton3.Enabled = false
else
PushButton3.Enabled = true
end if
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
listprinters
End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
dim s as string
if ListBox1.ListIndex>=0 then
s=Listbox1.cell(ListBox1.ListIndex,0)
ps.CurrentPrinterName=NewCFStringMBS(s)
if ps.LastError=0 then
ListPrinters
else
MsgBox "Error: "+str(ps.LastError)
end if
end if
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
dim p as CPMPageFormatMBS
dim s as CPMPrintSettingsMBS
s=NewCPMPrintSettingsMBS
p=NewCPMPageFormatMBS
call ps.PrintDialog(s,p)
End EventHandler
End Control
EventHandler Sub Open()
ps=NewCPMPrintSessionMBS
End EventHandler
Sub ListPrinters()
dim pc as CPMPrinterMBS
dim ar() as string
dim i,index,c as integer
dim r as CPMResolutionMBS
ListBox1.DeleteAllRows
ps.CreatePrinterList(ar,index,pc)
for each s as string in ar
ListBox1.AddRow s
if i=index then
ListBox1.CellBold(index,0)=true
end if
next
End Sub
Property ps As CPMPrintSessionMBS
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
End Project
See also:
The items on this page are in the following plugins: MBS MacCG Plugin.