Round Transparent Window?

I thought it would be nice to have a round splash screen when the user launches an application.

In Xojo I can’t do that, because if I write the code for transparent windows, everything on the window gets transparent.

So I wrote the code with another IDE product for Macintosh which does the work. But instead of having one app, I have two apps now. I want to get rid of the splash screen app…

How can I have a round or oval window in Xojo? Is there a way?

Can you help?

I only know that this is not trivial. Perhaps you want to have a look at the MBS Plugins which, I think, can do this.

Haha :slight_smile: That’s a very good idea. I already have more than half a dozen MBS plugins. Before I have more plugins, I wanted to know if there is a native solution to it :slight_smile:

If you decide to do it yourself, you’ll need to use declares. There is no native Xojo way.

Yes, I tried this, but it makes everything invisible, even the controls inside the window are affected:

#if TargetCocoa
declare sub setAlphaValue lib “Cocoa” selector “setAlphaValue:” (windowRef as integer, windowAlpha as Single)
setAlphaValue(MainWindow.handle, .6)
#endif

I don’t know how to apply only for the window frame.

For a transparent background you set Opaque off and the background color clear. This is the method I use. If calling from the Windows open event just pass in self. If calling at some later time also pass in true and it’ll fix the shadows. Then for a custom background draw in the Windows paint event and you can even use semi-transparent colors and it’s see through with corresponding shadow.

[code]Shared Sub makeWindowTransparent(aWindow As Window, forceDisplay As boolean = false)
if aWindow = nil then return

const CocoaLib = “Cocoa.framework”
soft declare function NSClassFromString lib CocoaLib (aClassName as CFStringRef) as Ptr
soft declare function colorMaker lib CocoaLib selector “colorWithCalibratedWhite:alpha:” (NSColorClass As Ptr, white As Single, alpha As Single) As Ptr
soft declare sub setBGColor lib CocoaLib selector “setBackgroundColor:” (NSWindow As Ptr, backgroundColor As Ptr)
soft declare sub setOpaque lib CocoaLib selector “setOpaque:” (NSWindow As Ptr, flag As Byte)

dim w As Ptr = Ptr(aWindow.Handle)

setOpaque(w, 0) //0 = off, 1 = on

setBGColor(w, colorMaker(NSClassFromString(“NSColor”), 1, 0))

if forceDisplay then
soft declare sub invalidateShadow lib CocoaLib selector “invalidateShadow” (NSWindow As Ptr)
soft declare sub disp lib “AppKit” selector “display” (windRef As Ptr)
disp(w)
invalidateShadow(w)
end
End Sub
[/code]

Thank you.

In 10.6.8 that leaves the title bar visible

Why then not use a plain window? :slight_smile:

using document, rounded or plain box did not work … using metal window did!

Anyone have a solution for the same thing on Windows?

There’s an example that comes with Xojo (in Example Projects\\Platform-Specific\\Windows\\CustomWindowShape) that demonstrates masking a window to a shape defined in a Picture; and the Windows Functionality Suite has code to set the alpha/transparency of a window.

Thanks Andrew

Well, we have OverlayMBS class in our plugins to do this…

I’m using MakeTransparentMBS for a SplashScreen on OSX, but it does not seem to work on Windows, the window is not becoming transparent …

https://forum.xojo.com/1874-the-easiest-way-i-ve-found-to-make-a-splash-screen/p1#p18183

Of course not. MakeTransparentMBS on Windows first enables the use of the TransparencyMBS property.

I’m not able to find TransparencyMBS in your docu (just tons of listarchive entries). I obviously am missing something here, because I don’t know on how to make my example (splash.zip) work on Windows, using your plugins.

Could you help with a link to a Windows example and/or a link to the specific docu?

I’m sorry, but on Windows things are different.
You would need to use OverlayMBS class and not a Xojo window.

[quote]Shared Sub makeWindowTransparent(aWindow As Window, forceDisplay As boolean = false)
if aWindow = nil then return

const CocoaLib = “Cocoa.framework”
soft declare function NSClassFromString lib CocoaLib (aClassName as CFStringRef) as Ptr
soft declare function colorMaker lib CocoaLib selector “colorWithCalibratedWhite:alpha:” (NSColorClass As Ptr, white As Single, alpha As Single) As Ptr
soft declare sub setBGColor lib CocoaLib selector “setBackgroundColor:” (NSWindow As Ptr, backgroundColor As Ptr)
soft declare sub setOpaque lib CocoaLib selector “setOpaque:” (NSWindow As Ptr, flag As Byte)

dim w As Ptr = Ptr(aWindow.Handle)

setOpaque(w, 0) //0 = off, 1 = on

setBGColor(w, colorMaker(NSClassFromString(“NSColor”), 1, 0))

if forceDisplay then
soft declare sub invalidateShadow lib CocoaLib selector “invalidateShadow” (NSWindow As Ptr)
soft declare sub disp lib “AppKit” selector “display” (windRef As Ptr)
disp(w)
invalidateShadow(w)
end
End Sub[/quote]

Hello,

how do i use it for a window?
I tested this 3 variants but nothing works (getting errors of wrong calls)

self.makeWindowTransparent
self.makeWindowTransparent aWindow
self.makeWindowTransparent forceDisplay As boolean = false

Thanks

Can you try makeWindowTransparent(self, false)?