In a Listbox I am attempting to draw the application icon together with the corresponding application name. When inserting the code below in the CellBackgroundPaint event of the listbox, I get the generic file icon for all application names, bur not the individual icons:
Dim f As FolderItem
Dim Icon as Picture
f = GetFolderItem(Path)
dim n as NSImageMBS = NSWorkspaceMBS.iconForFile(f)
n.size = new NSSizeMBS(16,16)
Icon = n.CopyPictureWithMask
However, when I insert the above code in the Paint event of a canvas, the desired icon is drawn.
I have searched all examples, for both Xojo and for MBS, but have found no solution to the problem.
Any help will be greatly appreciated.
The problem isn’t getting the image, as you may see from the code in my original question. The icon obtained in this way draws nicely when invoked from the Paint event of a Canvas. However, when this code is applied to a Listbox, only the generic icon for a file is drawn.
Private Function GetApplicationIcon(theBundleIdentifier as String) As NSImageMBS
dim theApp as FolderItem = LaunchServicesFindApplicationForInfoMBS("", theBundleIdentifier,"")
if theApp = nil then Return nil
if RetinaScaleFactor = 0 then RetinaScaleFactor = globals.getRetinaScalingFactor(self.Window)
dim theNSImage as NSImageMBS = NSWorkspaceMBS.iconForFile(theApp)
if RetinaScaleFactor = 1 then
theNSImage.size = new NSSizeMBS(16, 16)
theNSImage.size = new NSSizeMBS(32, 32)