Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/Carbon Printing/Change current printer
Feedback.

Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /MacOSX/Carbon Printing/Change current printer
This example is the version from Wed, 2nd Oct 2007.
Notes: Last modified: Wed, 2nd Oct 2007
Class App
Inherits Application
// Constants
Const kFileQuitShortcut = Ctrl+Q
Const kFileQuit = E&xit
Const kEditClear = &Delete
End Class

Class Window1
Inherits Window
// Controls
ControlInstance
Sub Change() Handles Event
if me.listindex = -1 then
PushButton3.Enabled = false
else
PushButton3.Enabled = true
end if
End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event

listprinters

End Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
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 Sub
End ControlInstance
ControlInstance
Sub Action() Handles Event
dim p as CPMPageFormatMBS
dim s as CPMPrintSettingsMBS

s=NewCPMPrintSettingsMBS
p=NewCPMPageFormatMBS
call ps.PrintDialog(s,p)
End Sub
End ControlInstance

// Properties
Dim ps As CPMPrintSessionMBS

// Event implementations
Sub Open()

ps=NewCPMPrintSessionMBS

End Sub

// Methods
Sub ListPrinters()
dim pc as CPMPrinterMBS
dim ar as CFArrayMBS
dim i,index,c as integer
dim o as CFObjectMBS
dim r as CPMResolutionMBS
dim s as CFStringMBS

ListBox1.DeleteAllRows

ps.CreatePrinterList(ar,index,pc)

if ar<>nil then
c=ar.Count-1
for i=0 to c
s=CFStringMBS(ar.Item(i))
if s<>Nil then
ListBox1.AddRow s.str

if i=index then
ListBox1.CellBold(index,0)=true
end if
end if
next
end if

End Sub
End Class


See also:




Links
MBS REALstudio Plugins - Nachhilfe in Wassenach