Title Bar off Floating Window In Cocoa

First, can you call a Carbon API call in Xojo 2019?

Second, I used to use this code to take a title bar off a floating window. What would be the Cocoa equivilant?

Soft Declare Function ChangeWindowAttributes Lib "Carbon" (inWindow as WindowPtr, setAttrs As Integer, clearAttrs As Integer) as Integer Dim OSErr as Integer OSErr = ChangeWindowAttributes(self, pow(2, 7), 0)

Carbon is only 32bit… so don’t think so.
and wouldn’t that just be a “Plain Box” anyways?

It depends on what you want.

Do you want to keep the window title visible? The Window widgets available (close, minimize and maximize fullscreen)?

Let me reply Dave+Sam…

I want a Plain Box look (no title bar) but I want the functionality of Floating Window which is always the topmost Window within the app. (Dave: The Plain Box doesn’t do this.)

The code in the question makes a Floating Window look like a Plain Box, but of course the call is a Carbon call. My question is: What is the Cocoa equivalent? Or, in Dave terms, I’d use a Plain Box, but how can you make it always the topmost window? What is an appropriate Cocoa call in that case?

BTW, this is for a very typical Splash Screen that shows when app is starting up. My scheme is that the Splash Screen shows up, has a Label that shows what is going on (“init this, init that”), then the main application screen appears UNDERNEATH the Splash Screen, and then 1-2 seconds afterward the Splash Screen fades out, completing the nice dovetail effect. Sam, typically Splash Screens are just a graphical box and don’t have title bars.

(And, giving a heads up, I have about 8 other Carbon calls that I need to find a Cocoa equivalent for. There isn’t a common list of these, is there? I googled, didn’t find anything (yet).)

There is a specific Cocoa function I currently use to keep any kind of windows as topmost window. So no need of floating windows.
(The snippet below is taken from MacOSLib-64-bit but it should work on its own).

[code]Public Sub AlwaysOnTop(extends w as Window, assigns Value as Boolean)
//# Sets the window’s window level to floating window level.

#if TargetCocoa then
Const NSNormalWindowLevel = 0
Const NSFloatingWindowLevel = 3
Const NSModalPanelWindowLevel = 8
Const NSDockWindowLevel = 20
Const NSMainMenuWindowLevel = 24
Const NSPopUpMenuWindowLevel = 101
Const NSScreenSaverWindowLevel = 1001

declare sub NSWindowSetLevel lib "Cocoa" selector "setLevel:" (WindowRef as integer, Level as Integer)
if Value then
  NSWindowSetLevel w.Handle, NSFloatingWindowLevel
else
  NSWindowSetLevel w.Handle, NSNormalWindowLevel
end if

#else
#pragma Unused w
#pragma Unused Value
#endif
End Sub
[/code]

64-Bit Xojo built apps still use Carbon, if it were 32-Bit only, they wouldn’t be able to do so.

I don’t think that a floating window or global floating window is the right tool for the job. A floating window will disappear when the user switches applications and a global floating window will float above other app windows (through declares it can be hacked to lock it to the application’s window group), but you’re then doing a lot of declares, all of which can break when Apple does an OS release.

Instead look at a Modal dialog, simply call “show” on it and not 'showModal". This should give you want you want.

But I doubt seriously if they will run under Catalina anymore

App Wrapper 3 works on macOS 10.15.1

App Wrapper 3 Executable ( Mach-O file ) 21.7 MB Created 3 Nov, 2019, 4:03:34 PM Modified 3 Nov, 2019, 4:03:46 PM Codesigned Dev. ID - Ohanaware Co., LTD (QXAFMEPH6X) Architecture Intel 64-Bit UUID A895EE7B-1C54-36A8-BC50-32D1F25143AE Min OS 10.9 ( SDK: 10.9) ?? Uses Carbon HIObjects. Libraries ? /usr/lib/dyld ? /usr/lib/libSystem.B.dylib ? /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation ? /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation ? /usr/lib/libobjc.A.dylib ? /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit ? /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices ? /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon ? /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa ? /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics ? /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices ? /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO ? /System/Library/Frameworks/QuickLook.framework/Versions/A/QuickLook ? /System/Library/Frameworks/Security.framework/Versions/A/Security ? /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration ? /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit ? @executable_path/../Frameworks/XojoFramework.framework/Versions/A/XojoFramework