Modal window with close button and title

I must be missing something, but I can’t seem to create a modal window on MacOS that has both a title and a close button on the title bar.
Movable modal doesn’t display the button.
Modal doesn’t display either

Must I create a ‘close this dialog’ button of my own?

1 Like

Found this on an old post, from Paul Lefebvre

#If TargetCocoa
Const NSTitledWindowMask = 1
Const NSClosableWindowMask = 2

Declare Sub setStyleMask Lib “Cocoa.framework” _
selector “setStyleMask:” (obj_id As Integer, mask As Integer)

setStyleMask(Self.Handle, NSTitledWindowMask Or NSClosableWindowMask)


#EndIf

Deprecated by Apple of course, because reasons.

This is what I use in one of my apps.

This solution is not working for me on API 2.0 because Self.Handle now returns Ptr instead of Integer.

Using Self.Handle.Integer causes a crash.

Any ideas?

Figured it out. You can use the OSHandle data type.

New code for use on a DesktopWindow:

#If TargetMacOS
Const NSTitledWindowMask = 1
Const NSClosableWindowMask = 2
Declare Sub setStyleMask Lib "Cocoa.framework" selector "setStyleMask:" (obj_id As Integer, mask As Integer)

Var WinHandle as OSHandle
WinHandle = Self.Handle

setStyleMask(WinHandle, NSTitledWindowMask Or NSClosableWindowMask)
#EndIf