Icon on windows

Many Apps show their icon and the title at the top of a window, How can I do this for my App using Xojo? There is no window.icon?

Check out WindowProxyIconFileMBS (Monkeybread Xojo plugin - DesktopWindow). If you want a declare check out macOS lib if this is available for ARM. Sam Rowlands Ohanaware App Kit surely supports proxy icons, too.

Beatrix, thank you very much, that’s helpful. So, are you saying that Xojo does not offer use of an icon in the window title then?

Yes, the proxy icon is not part of Xojo functionality.

You can do it with a declare if you don’t have the MBS suite or AppKit.

Public Sub DocumentFileForTitlebar(fDoc as FolderItem)
  #if TargetMacOS then
    declare sub setTitleWithRepresentedFilename lib "Cocoa" selector "setTitleWithRepresentedFilename:" _
    (NSWindow as Ptr, filePath as CFStringRef)
    
    setTitleWithRepresentedFilename(ptr(self.Handle), fDoc.NativePath)
    
  #endif
End Sub

Tested and confirmed working with both DesktopWindow and Window.

2 Likes

Tim
I’m new to such code, so I have maybe done this wrong. But I get a syntax error on the line after End Sub?

Copy the code above,
Add a new Module,
Give it a meaningful name,
Select the Module (in the navigator pane),
EditMenu → Paste (with the mouse).

Click to open the new Module:
the Method is here

Or…
Add a Method,
Paste the code between Public Sub and End Sub,
Then Copy the Public Sub line and paste it in the new Method Name…

See blog post at Showing an App Icon for 64-bit Windows Apps – Xojo Programming Blog