Platforms to show: All Mac Windows Linux Cross-Platform

Back to WindowsDeviceModeMBS class.

WindowsDeviceModeMBS.ApplyToSetupString(SetupString as String) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Printing MBS Win Plugin 17.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Applies current device mode to the given setup string.
Example
dim p as new PrinterSetup

if p.PageSetupDialog then

dim w as WindowsDeviceModeMBS = WindowsDeviceModeMBS.FromSetupString(s)

w.Copies = 3
w.Fields = BitwiseOr(w.Fields, w.DM_COPIES)

dim s as string = w.SetupString
dim t as string = w.ApplyToSetupString(s)

Break // check

end if

The setup string contains a device mode and we replace the one from Xojo with our own.
The other information is kept the same.

WindowsDeviceModeMBS.Constructor

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Printing MBS Win Plugin 12.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a new empty device mode.

Size is set for you to default name of the data structure.

WindowsDeviceModeMBS.RawData(Unicode as boolean = true) as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Printing MBS Win Plugin 13.1 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Copies the raw data of the WindowsDeviceModeMBS class.

Returns nil on any error.
If Unicode is true, we use DEVMODEW and if Unicode is false, we use DEVMODEA structure.

WindowsDeviceModeMBS.SetupString(ActualHorizontalResolution as integer, ActualVerticalResolution as integer, MaxHorizontalResolution as integer, MaxVerticalResolution as integer, MarginLeft as integer = 2500, MarginRight as integer = 2500, MarginTop as integer = 2500, MarginBottom as integer = 2500, MinMarginLeft as integer = 0, MinMarginRight as integer = 0, MinMarginTop as integer = 0, MinMarginBottom as integer = 0, PageSetupFlags as integer = 8) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Printing MBS Win Plugin 17.2 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a setup string from devmode.

This setupstring is empty on error.
If not empty, you can assign to PrinterSetup.SetupString.

Please pass reasonable flags.
Check existing SetupStrings from Xojo for possible values.
Resolution parameters can e.g. bei 72.

Supports Xojo 2017r1 with 17.3 plugins.

See also:

WindowsDeviceModeMBS.SetupString(Margin as Integer = 2500) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Printing MBS Win Plugin 14.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a setup string from devmode.
Example
dim p as new PrinterSetup

// setup something
call p.PageSetupDialog

// now we have nice setupstring
dim ss as string = p.SetupString

// parse it in device mode
dim d as WindowsDeviceModeMBS = WindowsDeviceModeMBS.FromSetupString(ss)

// duplex is?
MsgBox "Duplex: "+str(d.Duplex)

// change printer
d.DeviceName = "Deskjet 2540 series#:2"

// enable duplex
d.Fields = BitwiseOr(d.Fields, d.DM_DUPLEX)
d.Duplex = d.DMDUP_HORIZONTAL

// now duplex is?
MsgBox "Duplex: "+str(d.Duplex)

// get back as setup string
dim da as string = d.SetupString

if da = "" then
MsgBox "failed to create setup string"
Return
end if

// assign back
p.SetupString = da

// take a look
call p.PageSetupDialog

// and print something
dim g as Graphics = OpenPrinter(p)

g.DrawString "Page 1", 20, 20
g.NextPage
g.DrawString "Page 2", 20, 20

This setupstring is empty on error.
If not empty, you can assign to PrinterSetup.SetupString.

Supports Xojo 2017r1 with 17.3 plugins.

See also:

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


The biggest plugin in space...