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?
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?
@MikeCharlesworth 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?
On Mac, why not use a canvas instead ?
@Tim J Do you have an example of what you're trying to achieve?
A custom shape window
If you have an MBS plugin license, @ChristianSchmitz 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.
@MikeCharlesworth A custom shape window
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.
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
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
@MikeCharlesworth 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?
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?
@Sam R 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?
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.
@Will S Put this in your sheet windows open event to make the background completely transparent. Controls will still be visible.
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 SubAnd 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
Thanks Will, thats the one...