//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.
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
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.