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)
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 windows window level to floating window level.
declare sub NSWindowSetLevel lib "Cocoa" selector "setLevel:" (WindowRef as integer, Level as Integer)
if Value then
NSWindowSetLevel w.Handle, NSFloatingWindowLevel
NSWindowSetLevel w.Handle, NSNormalWindowLevel
#else #pragma Unused w #pragma Unused Value #endif
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.