You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCG/CoreGraphics DirectDisplay/
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
if not TargetMachO then
MsgBox "This example needs Mac OS X."
end if
End EventHandler
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open()
w = new MyCGDisplayReconfigurationEventMBS
End EventHandler
Property w As MyCGDisplayReconfigurationEventMBS
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
Class MyCGDisplayReconfigurationEventMBS Inherits CGDisplayReconfigurationEventMBS
EventHandler Sub DisplayReconfiguration(DisplayID as integer, flags as integer)
dim flagnames(-1) as string
if bitwiseAnd(flags, kCGDisplayUnMirrorFlag) <> 0 then
flagnames.Append "UnMirror"
end if
if bitwiseAnd(flags, kCGDisplaySetModeFlag) <> 0 then
flagnames.Append "SetMode"
end if
if bitwiseAnd(flags, kCGDisplaySetMainFlag) <> 0 then
flagnames.Append "SetMain"
end if
if bitwiseAnd(flags, kCGDisplayRemoveFlag) <> 0 then
flagnames.Append "Remove"
end if
if bitwiseAnd(flags, kCGDisplayMovedFlag) <> 0 then
flagnames.Append "Moved"
end if
if bitwiseAnd(flags, kCGDisplayMirrorFlag) <> 0 then
flagnames.Append "Mirror"
end if
if bitwiseAnd(flags, kCGDisplayEnabledFlag) <> 0 then
flagnames.Append "Enabled"
end if
if bitwiseAnd(flags, kCGDisplayDisabledFlag) <> 0 then
flagnames.Append "Disabled"
end if
if bitwiseAnd(flags, kCGDisplayDesktopShapeChangedFlag) <> 0 then
flagnames.Append "DesktopShapeChanged"
end if
if bitwiseAnd(flags, kCGDisplayBeginConfigurationFlag) <> 0 then
flagnames.Append "BeginConfiguration"
end if
if bitwiseAnd(flags, kCGDisplayAddFlag) <> 0 then
flagnames.Append "Add"
end if
window1.List.AddRow "Display "+str(DisplayID)+" changed: "+Join(flagnames)
End EventHandler
End Class