You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics DirectDisplay/Capture Screen with
Class Window1 Inherits Window
EventHandler Sub Close()
dim e as integer
w.cancel=True
do
loop until w.finished
e=display.ShowCursor
e=display.ReleaseAllDisplays
End EventHandler
EventHandler Function KeyDown(Key As String) As Boolean
if asc(key)=27 then // esc
quit
Return true
end if
End EventHandler
EventHandler Sub Open()
dim e as integer
display = CGDisplayMBS.MainDisplay // main screen
e=display.CaptureAllDisplays
e=display.HideCursor
w=new WorkThread
w.display = Display
w.run
End EventHandler
Property Protected display As CGDisplayMBS
Property Protected w As workThread
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open()
MsgBox "Command Q will stop it."
End EventHandler
End Class
Class WorkThread Inherits Thread
EventHandler Sub Run()
finished=False
cancel=False
count=240 // start with white
do
work
loop until cancel
finished=true
End EventHandler
Protected Sub Work()
dim c as CGContextMBS = Display.DrawingContext
if c<>Nil then
c.SetRGBFillColor rnd, rnd, rnd, 1.0
c.FillRect CGMakeRectMBS(0,0,Display.PixelsWide,Display.PixelsHigh)
end if
End Sub
Property cancel As boolean
Property count As integer
Property display As CGDisplayMBS
Property finished As boolean
End Class