Can someone tell me how to set a Icon to the WindowBar?
Maybe this is the right code but I cant translate it :-/
[[<window> standardWindowButton:NSWindowDocumentIconButton] setImage:<image>]
Thanks
How to set a Icon to a WindowBar ?
How to set a Icon to a WindowBar ?
macOS Catalina 10.15.7
Re: How to set a Icon to a WindowBar ?
You may try to do it in two steps:Wolfram wrote:Can someone tell me how to set a Icon to the WindowBar?
1. You have to create a NSWindowsDocumentButton by yourself because a window created with OpenWindow() doesn't create one. Therefore your posted code always returns 0. The following code takes an existing file and displays its filename together with the corresponding icon to the left of the filename in the window's title bar:
Code: Select all
OpenWindow(0, 270, 100, 250, 170, "")
Filename$ = #PB_Compiler_Home + "Install.Txt"
CocoaMessage(0, WindowID(0), "setTitleWithRepresentedFilename:$", @Filename$)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindowCode: Select all
#NSWindowDocumentIconButton = 4
UsePNGImageDecoder()
If LoadImage(0, #PB_Compiler_Home + "logo.png")
OpenWindow(0, 270, 100, 230, 170, "")
Filename$ = #PB_Compiler_Home + "Install.Txt"
CocoaMessage(0, WindowID(0), "setTitleWithRepresentedFilename:$", @Filename$)
CocoaMessage(0, CocoaMessage(0, WindowID(0),
"standardWindowButton:", #NSWindowDocumentIconButton),
"setImage:", ImageID(0))
SetWindowTitle(0, "PureBasic rulez!")
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
