Make Sheet window transparent

How do you make the back of a sheet window transparent so you can draw the window yourself in the paint event of the window?

Do you have an example of what you’re trying to achieve?

On Mac, why not use a canvas instead ?

A custom shape window

If you have an MBS plugin license, @Christian Schmitz has a great overlay capability that works for all three platforms.

Check out this link on the MBS site: MBS Overlay Window Tutorial

Its an older video, but it still works in Xojo.

MacOSLib uses a custom shape splash window.

But since a sheet window, at least on Mac, always displays within another window, a canvas can do just what you described in your OP…

Put this in your sheet windows open event to make the background completely transparent. Controls will still be visible.

[code]Sub Open()
const Cocoa = “Cocoa”
declare sub setOpaque lib Cocoa selector “setOpaque:” (id As integer, b As boolean)
declare function NSClassFromString lib Cocoa (aClassName as CFStringRef) as Ptr
declare function clearColor lib Cocoa selector “clearColor” (NSColorClass As Ptr) As Ptr
declare sub setBackgroundColor lib Cocoa selector “setBackgroundColor:” (w As integer, c As Ptr)

//allow for transparency by setting opaqueness false
setOpaque(self.Handle, false)

//set the background completely transparent
setBackgroundColor(self.Handle, clearColor(NSClassFromString(“NSColor”)))

End Sub[/code]

And draw your custom background in Paint

Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.ForeColor = &c00FF0080 g.FillRect(0, 0, g.Width, g.Height) End Sub

Erm… The sheet window is already translucent…

Are you trying to create some kind of overlay dialog on your window content, like a progress window or something similar?

[quote=157082:@Sam Rowlands]Erm… The sheet window is already translucent…

Are you trying to create some kind of overlay dialog on your window content, like a progress window or something similar?[/quote]

I am making a custom shaped window which I am drawing on a canvas on the window. Therefore I want the canvas and contained controls to show while the sheet window is invisible.

[quote=157078:@Will Shank]Put this in your sheet windows open event to make the background completely transparent. Controls will still be visible.

[code]Sub Open()
const Cocoa = “Cocoa”
declare sub setOpaque lib Cocoa selector “setOpaque:” (id As integer, b As boolean)
declare function NSClassFromString lib Cocoa (aClassName as CFStringRef) as Ptr
declare function clearColor lib Cocoa selector “clearColor” (NSColorClass As Ptr) As Ptr
declare sub setBackgroundColor lib Cocoa selector “setBackgroundColor:” (w As integer, c As Ptr)

//allow for transparency by setting opaqueness false
setOpaque(self.Handle, false)

//set the background completely transparent
setBackgroundColor(self.Handle, clearColor(NSClassFromString(“NSColor”)))

End Sub[/code]

And draw your custom background in Paint

Sub Paint(g As Graphics, areas() As REALbasic.Rect) g.ForeColor = &c00FF0080 g.FillRect(0, 0, g.Width, g.Height) End Sub[/quote]

Thanks Will, thats the one…