Removing the title bar from a floating window

asked on Removing the title bar from a floating window - General - Xojo Forum
no answer :frowning:

for macOS in the open event (maybe the constructor as well) of a window

#If TargetMacOS
  Dim newStyle As UInt32 = 0 //no titlebar, not resizeable
  Soft Declare Sub setStyleMask Lib "Cocoa.framework" selector "setStyleMask:" (id As Ptr, mask As UInt32)
  setStyleMask(Ptr(Self.Handle), newStyle)

the masks are in NSWindow.h

typedef NS_OPTIONS(NSUInteger, NSWindowStyleMask) {
    NSWindowStyleMaskBorderless = 0,
    NSWindowStyleMaskTitled = 1 << 0,
    NSWindowStyleMaskClosable = 1 << 1,
    NSWindowStyleMaskMiniaturizable = 1 << 2,
    NSWindowStyleMaskResizable	= 1 << 3,
    /* Specifies a window with textured background. Textured windows generally don't draw a top border line under the titlebar/toolbar. To get that line, use the NSUnifiedTitleAndToolbarWindowMask mask.
    NSWindowStyleMaskTexturedBackground API_DEPRECATED("Textured window style should no longer be used", macos(10.2, 11.0)) = 1 << 8,
    /* Specifies a window whose titlebar and toolbar have a unified look - that is, a continuous background. Under the titlebar and toolbar a horizontal separator line will appear.
    NSWindowStyleMaskUnifiedTitleAndToolbar = 1 << 12,
    /* When set, the window will appear full screen. This mask is automatically toggled when toggleFullScreen: is called.
    NSWindowStyleMaskFullScreen API_AVAILABLE(macos(10.7)) = 1 << 14,
    /* If set, the contentView will consume the full size of the window; it can be combined with other window style masks, but is only respected for windows with a titlebar.
     Utilizing this mask opts-in to layer-backing. Utilize the contentLayoutRect or auto-layout contentLayoutGuide to layout views underneath the titlebar/toolbar area.
    NSWindowStyleMaskFullSizeContentView API_AVAILABLE(macos(10.10)) = 1 << 15,
    /* The following are only applicable for NSPanel (or a subclass thereof)
    NSWindowStyleMaskUtilityWindow			= 1 << 4,
    NSWindowStyleMaskDocModalWindow 		= 1 << 6,
    NSWindowStyleMaskNonactivatingPanel		= 1 << 7, // Specifies that a panel that does not activate the owning application
    NSWindowStyleMaskHUDWindow API_AVAILABLE(macos(10.6)) = 1 << 13 // Specifies a heads up display panel
1 Like

I let the OP know about your post here.


oh trust me he knows :slight_smile:
I sent it directly to him off list

I didn’t realize who the OP was… :roll_eyes:, but anyway it looks like I never finished the message because I can’t find it anymore.

As a side note, it is fun to try to circunvent black listed words and urls that are banned in TOF.

Xojo MAY have removed it

The URL one is easy - plop the url from here into bitly and it will give you a mangled one that works there

I believe bitly doesn’t work, I know for sure some shortened urls are blocked, but if you try several of those pages you end up finding one that is allowed.

I have posted bitly ones before but its possible they block them selectively

Lord knows

Thanks Norm. An awesomely helpful answer as usual.

Here’s a super simple Xojo project illustrating how to do it on all three platforms using declares:

Binary Project Link