Platforms to show: All Mac Windows Linux Cross-Platform
/Util/Threads/Listbox InvalidateCell on Thread
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Threads/Listbox InvalidateCell on Thread
This example is the version from Thu, 9th Oct 2013.
Project "Listbox InvalidateCell on Thread.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Thread1 Inherits Thread
ControlInstance Thread1 Inherits Thread
EventHandler Sub Run()
dim n as integer = 0
do
me.Sleep(1000)
colors(n) = rgb(rnd*256, rnd*256, rnd*256)
Listbox1.InvalidateCellThreadSafeMBS n,0
n = n +1
if n = 10 then n = 0
loop
End EventHandler
End Control
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
EventHandler Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean
if row<=UBound(colors) then
g.ForeColor = colors(row)
g.FillRect 0, 0, g.Width, g.Height
Return true
end if
End EventHandler
EventHandler Sub Open()
for i as integer = 0 to 9
me.AddRow ""
colors.Append rgb(rnd*256, rnd*256, rnd*256)
next
End EventHandler
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
EventHandler Sub Open()
Thread1.run
End EventHandler
Property colors() As color
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
The items on this page are in the following plugins: MBS Util Plugin.