Borderless transparent windows

Can we have “Transparent Windows” so users could customize them to any shape drawing the background?

I don’t think there’s a way to do this in Xojo. I know it can be done in Windows using declares; there’s a demonstration of this in the example projects that ship with Xojo called “CustomWindowShape”.

I do it in Cocoa this way (don’t know about Windows / Linux):

// In a window's Open() event #if TargetCocoa Declare Function colorWithCalibratedWhite Lib "AppKit" Selector "colorWithCalibratedWhite:alpha:" (NSColorClass As Ptr, white As Single, alpha As Single) As Ptr Declare Sub setBackgroundColor Lib "AppKit" Selector "setBackgroundColor:" (NSWindow As Ptr, backgroundColor As Ptr) Declare Sub setOpaque Lib "AppKit" Selector "setOpaque:" (NSWindow As Ptr, flag As Byte) setOpaque(Ptr(win.Handle), 0) // Zero for NO in Objective C setBackgroundColor(Ptr(win.Handle), colorWithCalibratedWhite(NSClassFromString("NSColor"), 1, 0)) #endif // And in the window's Paint() event #if TargetCocoa g.ForeColor = YourWindowBackgroundColor g.FillPolygon(... // Draw the shape of you irregularly shaped window #endif

Should be great to add the Chromeless Transparent Window (rect with no frame/buttons/etc and no background painting at runtime [or background color alpha=0]) type to the list to be able to do this platform independent with no user side tricks:

Thanks for this piece of code. I have been trying this for yonks - this is the first time I have gotten results.
MUCH appreciated

ever so slight addition (os x, 10.8.4) - required addition of first declare function in open()

// In a window’s Open() event
#if TargetCocoa
declare function NSClassFromString lib “Cocoa” (aClassName as CFStringRef) as Ptr
Declare Function colorWithCalibratedWhite Lib “AppKit” Selector “colorWithCalibratedWhite:alpha:” (NSColorClass As Ptr, white As Single, alpha As Single) As Ptr
Declare Sub setBackgroundColor Lib “AppKit” Selector “setBackgroundColor:” (NSWindow As Ptr, backgroundColor As Ptr)
Declare Sub setOpaque Lib “AppKit” Selector “setOpaque:” (NSWindow As Ptr, flag As Byte)
setOpaque(Ptr(Window1.Handle), 0) // Zero for NO in Objective C
setBackgroundColor(Ptr(Window1.Handle), colorWithCalibratedWhite(NSClassFromString(“NSColor”), 1, 0))
#endif
// And in the window’s Paint() event
// added triangle just to save time
Dim Points() as Integer
Points=Array(10,10,100,50,10,200,10,10)

#if TargetCocoa
g.ForeColor=RGB(100,200,255)
g.FillPolygon Points
#endif