Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

Next items

CGDisplayMBS.AllDisplayModes as CGDisplayModeMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Return an array of all modes for the specified display.
Example:
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay
dim modes(-1) as string
for each mode as CGDisplayModeMBS in d.AllDisplayModes
modes.append str(mode.Width)+" x "+str(mode.Height)
next
MsgBox Join(modes,EndOfLine)
Notes:
Returns an empty array on any error.
Requires Mac OS X 10.6

Feedback, Comments & Corrections

CGDisplayMBS.AvailableModes as Dictionary()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Returns an array filled with dictionaries (one for each mode).
Example:
// Display all available graphic modes:

Listbox1.DeleteAllRows
Listbox1.ColumnCount = 4

dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay

dim a(-1) as Dictionary = d.AvailableModes

for each di as Dictionary in a

Listbox1.AddRow di.Value(d.kCGDisplayMode).stringValue
Listbox1.cell(Listbox1.LastIndex,1) = di.Value(d.kCGDisplayWidth)+" x "+di.Value(d.kCGDisplayHeight)
Listbox1.cell(Listbox1.LastIndex,2) = di.Value(d.kCGDisplayRefreshRate)
Listbox1.cell(Listbox1.LastIndex,3) = di.Value(d.kCGDisplayBitsPerPixel)

next
Notes: Returns empty error on any error.

Feedback, Comments & Corrections

CGDisplayMBS.BestModeForParameters(BitsPerPixel as Integer, Width as Integer, Height as Integer, byref ExactMatch as boolean) as Dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Returns a Dictionary with the best mode found for the given parameters.
Notes:
Returns nil on any error.

Try to find a display mode of specified depth with dimensions equal or greater than specified.
If no depth match is found, try for the next larger depth with dimensions equal or greater than specified. If no luck, then just return the current mode.

exactmatch is set to 'true' if an exact match in width, height, and depth is found, and 'false' otherwise.
Returns nil if display is invalid.

Feedback, Comments & Corrections

CGDisplayMBS.BestModeForParametersAndRefreshRate(BitsPerPixel as Integer, Width as Integer, Height as Integer, RefreshRate as Integer, byref ExactMatch as boolean) as Dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Returns a Dictionary with the best mode found for the given parameters.
Notes:
Returns nil on any error.

Try to find a display mode of specified depth with dimensions equal or greater than specified.
If no depth match is found, try for the next larger depth with dimensions equal or greater than specified. If no luck, then just return the current mode.

exactmatch is set to 'true' if an exact match in width, height, and depth is found, and 'false' otherwise.
Returns nil if display is invalid.

Feedback, Comments & Corrections

CGDisplayMBS.BestModeForParametersAndRefreshRateWithProperty(BitsPerPixel as Integer, Width as Integer, Height as Integer, RefreshRate as Integer, propertyName as string, byref ExactMatch as boolean) as Dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Returns a Dictionary with the best mode found for the given parameters.
Notes:
Returns nil on any error.

Try to find a display mode of specified depth with dimensions equal or greater than specified.
If no depth match is found, try for the next larger depth with dimensions equal or greater than specified. If no luck, then just return the current mode.

exactmatch is set to 'true' if an exact match in width, height, and depth is found, and 'false' otherwise.
Returns nil if display is invalid.

Feedback, Comments & Corrections

CGDisplayMBS.Capture as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Captures this display for your use.
Example:
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay

if d.Capture = 0 then

dim c as CGContextMBS = d.DrawingContext

// watch it drawing red
c.SetRGBFillColor 1.0, 0.0, 0.0, 1.0
c.FillRect CGMakeRectMBS(0,0,d.PixelsWide,d.PixelsHigh)

DelayMBS 3.0

call d.Release
else
MsgBox "Failed to capture displays."
end if
Notes:
Don't forget to Release the display later.
Returns an error code.

Feedback, Comments & Corrections

CGDisplayMBS.CaptureWithOptions(options as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Captures this display for your use.
Example:
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay

if d.CaptureWithOptions(d.kCGCaptureNoOptions) = 0 then

dim c as CGContextMBS = d.DrawingContext

// watch it drawing red
c.SetRGBFillColor 1.0, 0.0, 0.0, 1.0
c.FillRect CGMakeRectMBS(0,0,d.PixelsWide,d.PixelsHigh)

DelayMBS 3.0

call d.Release
else
MsgBox "Failed to capture displays."
end if
Notes:
Don't forget to Release the display later.
Returns an error code.
Use kCGCaptureNoOptions and kCGCaptureNoFill for options parameter.

Feedback, Comments & Corrections

CGDisplayMBS.CreateImage as CGImageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Return an image containing the contents of the display.
Example:
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay
dim img as CGImageMBS = d.CreateImage

Backdrop = img.Picture
Notes: Requires Mac OS X 10.6.

Feedback, Comments & Corrections

CGDisplayMBS.CreateImageAsync(receiverDelegate as CreateImageAsyncDelegateMBS, jpegQuality as Double = 0.9, tag as Variant = nil)
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 15.3 Yes No No Yes, macOS only No
Function: Asynchronously creates an image with screenshot.
Notes:
If jpeg is >= 0, we use it as quality for the jpeg compression and provide the JPEG data as memoryblock in the delegate.
Tag is passed through as is.

Delegate declaration:
CreateImageAsyncDelegateMBS(img as CGImageMBS, JPEGData as MemoryBlock, Tag as Variant)

Feedback, Comments & Corrections

CGDisplayMBS.CreateImageForRect(rect as CGRectMBS) as CGImageMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Return an image containing the contents of the rectangle rect, specified in display space, of the display identified by self.
Example:
dim r as CGRectMBS = CGMakeRectMBS(100,100,500,500)
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay
dim img as CGImageMBS = d.CreateImageForRect(r)

Backdrop = img.Picture
Notes:
The actual rectangle used is the rectangle returned from CGRectIntegral(rect).
Requires Mac OS X 10.6.

Feedback, Comments & Corrections

CGDisplayMBS.DrawingContext as CGContextMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Return a CGContext suitable for drawing to the captured display, or nil if display has not been captured.
Example:
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay

if d.Capture = 0 then

dim c as CGContextMBS = d.DrawingContext

// watch it drawing red
c.SetRGBFillColor 1.0, 0.0, 0.0, 1.0
c.FillRect CGMakeRectMBS(0,0,d.PixelsWide,d.PixelsHigh)

DelayMBS 3.0

call d.Release
else
MsgBox "Failed to capture displays."
end if
Notes:
The context is owned by the device and should not be released by the caller.

The context remains valid while the display is captured and while the display configuration is unchanged. Releasing the captured display or reconfiguring the display invalidates the drawing context.

The determine when the display configuration is changing, use
CGDisplayReconfigurationEventMBS class.

Feedback, Comments & Corrections

CGDisplayMBS.GetDisplayTransferByTable(capacity as Integer, red as memoryblock, green as memoryblock, blue as memoryblock, byref samplecount as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Get transfer tables.
Notes:
Capacity should contain the number of samples each array can hold, and sampleCount is filled in with the number of samples actually copied in.

You must pass in Memoryblocks with the given size (capacity*4 Bytes).
Returns an error code.

Feedback, Comments & Corrections

CGDisplayMBS.GetDisplayTransferFormula(byref formula as CGDisplayTransferFormulaMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Queries the display for the current gamma formula.
Notes: Returns an error code.

Feedback, Comments & Corrections

CGDisplayMBS.HideCursor as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Hides the mouse cursor.
Notes:
Returns an error code.
Decrements hide cursor count.

Feedback, Comments & Corrections

CGDisplayMBS.Info as Dictionary
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 8.6 Yes No No Yes, macOS only No
Function: Returns the information CFDictionary about the display.
Example:
dim c as CGDisplayMBS = CGDisplayMBS.MainDisplay
dim d as Dictionary = c.Info

MsgBox d.Value("DisplaySerialNumber")
Notes:
On any error the return value is nil.
This function leaks around 4 to 16 KB of memory on Mac OS X 10.4. Not in the versions 10.3 or 10.5.

Feedback, Comments & Corrections

CGDisplayMBS.InfoAsCFDictionary as Variant
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 14.4 Yes No No Yes, macOS only No
Function: Returns the information CFDictionary about the display.
Notes:
On any error the return value is nil.
Returns a CFDictionaryMBS object. Returned as Variant to reduce plugin dependencies.

Feedback, Comments & Corrections

CGDisplayMBS.IsCaptured as boolean
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Returns true if you captured this display.
Example:
dim d as new CGDisplayMBS // pick main display

MsgBox str(d.IsCaptured)

Feedback, Comments & Corrections

CGDisplayMBS.MoveCursorToPoint(x as Double, y as Double) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Move the cursor to the specified point relative to the display origin (the upper left corner of the display).
Example:
Function KeyDown(Key As String) As Boolean
// in a window keydown event:

if asc(key)=32 then
dim c as new CGDisplayMBS
dim error as Integer = c.MoveCursorToPoint(200,200)

Title=str(error) // zero on success

end if

End Function
Notes:
Returns CGDisplayNoErr (0) on success.
No events are generated as a result of this move.
Points that would lie outside the desktop are clipped to the desktop.

Feedback, Comments & Corrections

CGDisplayMBS.OpenGLDisplayMask as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Return the OpenGL display mask for display, or 0 is display is an invalid display.

Feedback, Comments & Corrections

CGDisplayMBS.Release as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Releases the display.
Example:
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay

if d.Capture = 0 then

dim c as CGContextMBS = d.DrawingContext

// watch it drawing red
c.SetRGBFillColor 1.0, 0.0, 0.0, 1.0
c.FillRect CGMakeRectMBS(0,0,d.PixelsWide,d.PixelsHigh)

DelayMBS 3.0

call d.Release
else
MsgBox "Failed to capture displays."
end if
Notes: Returns an error code.

Feedback, Comments & Corrections

CGDisplayMBS.SetDisplayMode(mode as CGDisplayModeMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Switch the display mode to mode.
Notes:
The selected display mode persists for the life of the program, and automatically reverts to the permanent setting when the program terminates.

When changing display modes of displays in a mirroring set, other displays in the mirroring set will be set to a display mode capable of mirroring the bounds of the largest display being explicitly set.

Note that after switching, display parameters and addresses may change.

Feedback, Comments & Corrections

CGDisplayMBS.SetDisplayTransferByByteTable(count as Integer, red as memoryblock, green as memoryblock, blue as memoryblock) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Set a display gamma/transfer function using tables of data for each channel.
Notes:
As a convenience, allow setting of the gamma table by byte values.
Returns an error code.

Feedback, Comments & Corrections

CGDisplayMBS.SetDisplayTransferByTable(count as Integer, red as memoryblock, green as memoryblock, blue as memoryblock) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Set a display gamma/transfer function.
Notes:
Set a display gamma/transfer function using tables of data for each channel.
Values within each table should have values in the range of 0.0 through 1.0.
The same table may be passed in for red, green, and blue channels. 'count' indicates the number of entries in each table.
The tables are interpolated as needed to generate the number of samples needed by hardware.

Returns an error code.

Feedback, Comments & Corrections

CGDisplayMBS.SetDisplayTransferFormula(formula as CGDisplayTransferFormulaMBS) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Set a display gamma/transfer function.
Notes:
Set a display gamma/transfer function from a formula specifying min and max values and a gamma for each channel.
Gamma values must be greater than 0.0.
To get an antigamma of 1.6, one would specify a value of (1.0 / 1.6)
Min values must be greater than or equal to 0.0 and less than 1.0.
Max values must be greater than 0.0 and less than or equal to 1.0.
Out of range values, or Max greater than or equal to Min result in a kCGSRangeCheck error.

Values are computed by sampling a function for a range of indices from 0 through 1: value = Min + ((Max - Min) * pow(index, Gamma))
The resulting values are converted to a machine specific format and loaded into hardware.

Returns an error code.

Feedback, Comments & Corrections

CGDisplayMBS.SetRotation(angle as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 13.0 Yes No No Yes, macOS only No
Function: Rescans the bus of displays and changes the rotation of the display.
Example:
dim d as CGDisplayMBS = CGDisplayMBS.MainDisplay
dim e as Integer = d.SetRotation(90)

if e<>0 then
MsgBox "Error: "+str(e)
end if
Notes:
Returns IOKit error code. Zero means success.

Lasterror is set.

Feedback, Comments & Corrections

CGDisplayMBS.SetStereoOperation(stereo as boolean, forceBlueLine as boolean, option as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Immediately enable or disable stereo operation for a display.
Notes:
Note that the system normally detects the presence of a stereo window, and will automatically switch a display containing a stereo window to stereo operation. This function provides a mechanism to force a display to stereo operation, and to set options (such as blue line sync signal) when in stereo operation.

When in stereo operation, a display may need to generate a special stereo sync signal as part of the video output. The sync signal consists of a blue line which occupies the first 25% of the last scanline for the left eye view, and the first 75% of the last scanline for the right eye view. The remainder of the scanline is black. To force the display to generate this sync signal, pass true for forceBlueLine; otherwise, pass false.

Lasterror is set to kCGErrorSuccess on success, or kCGErrorRangeCheck if the display does not support the stereo operation settings requested.

On success, the display resolution, mirroring mode, and available display modes may change due to hardware-specific capabilities and limitations. You should check these settings to verify that they are appropriate for your application.

Lasterror is set.

Feedback, Comments & Corrections

CGDisplayMBS.ShieldingWindowID as UInt32
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 11.1 Yes No No Yes, macOS only No
Function: Returns window ID of the shield window for the captured display, or 0 if the display is not not shielded.

Feedback, Comments & Corrections

CGDisplayMBS.ShowCursor as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Shows the mouse cursor.
Notes:
Returns an error code.
Increments hide cursor count.

Feedback, Comments & Corrections

CGDisplayMBS.SwitchToMode(Mode as Dictionary) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
method CoreGraphics MBS MacCG Plugin 3.3 Yes No No Yes, macOS only No
Function: Switch display mode.
Notes:
Note that after switching, display parameters and addresses may change.
The selected display mode persists for the life of the program, and automatically reverts to the permanent setting made by Preferences when the program terminates.
The mode dictionary passed in must be a dictionary vended by other CGDirectDisplay APIs such as BestModeForParameters() and AvailableModes().
Returns an error code.

Feedback, Comments & Corrections

Next items

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




Links
MBS FileMaker blog