Set custom document icon in 64 bit OSX

I have been shipping in 32 bit for years.
When I save a document, I offer my users 3 options for the document icon

a/the document icon built into the app
b/an icon that is basically a screengrab of the app at the point of saving
c/a preview of the ‘whole document’ (rather like coverflow would show)

To do the latter, I have been using AddCustomIconMBS from MBS

It seems that in the 32bit build, this works.
In the 64bit build, I always get the original document icon.

Is there a replacement for 64bit work on a retina machine?

Current code

[code]
Protected Sub AddIcon(f as folderitem, optional p1 as picture)
dim x2 as picture
if p1 = nil then
x2 = newpicture(512,512,32)
mainimage.DrawInto x2.Graphics,0,0
else
x2 = p1
end if

#if TargetMacOS then

try
  dim ps,ms,m as Picture
  dim i as IconFamilyMBS
  dim n as Integer
  p =x2
  
  if p1 = nil then
    m=NewPicture(1,1,32)
    m.Graphics.ForeColor=rgb(0,0,0)
    m.Graphics.Fillrect 0,0,1,1
  else
    if theheight > thewidth then    //these are document wide variables
      m=NewPicture(theheight,theheight,32)
    else
      m=NewPicture(thewidth,thewidth,32)
    end if
    m.Graphics.ForeColor=rgb(255,255,255)
    m.Graphics.Fillrect 0,0,m.width,m.height
    m.Graphics.ForeColor=rgb(0,0,0)
    m.Graphics.Fillrect 0,0,chartwidth,chartheight
    
  end if
  i=NewIconFamilyMBS
  i.dither=true
  
  // For Mac OS X
  i.Thumbnail32BitData=p
  i.Thumbnail8BitMask=m
  
  // For Mac OS 9:
  i.Large8BitData=p
  i.Large1BitMask=m
  i.Large1BitData=p
  i.Large4BitData=p
  i.Large32BitData=p
  i.Large8BitMask=m
  
  // 512, 256, 128 Pixel images for Leopard
  ps=ScalePicture(p,512)
  ms=ScalePicture(m,512)
  call i.SetIconImage(ps,ms)
  ps=ScalePicture(p,256)
  ms=ScalePicture(m,256)
  call i.SetIconImage(ps,ms)
  ps=ScalePicture(p,128)
  ms=ScalePicture(m,128)
  call i.SetIconImage(ps,ms)
  
  
  if not f.Exists then
  else
    
    n=f.AddCustomIconMBS(i,true)
  end if
catch
end try

#endif
End Sub[/code]

I found a way to get the exceptions.
‘Only available in 32bit Carbon targets’

Looks like thats a dead end these days. :frowning:

Please use NSWorkspaceMBS.setIcon method.

http://monkeybreadsoftware.net/cocoa-nsworkspacembs-shared-method2.shtml#23

Thanks Christian.