Semi-transparent window

Hi everybody!

I need the help of some pros…

I tried to make a window semi-transparent on macOS and Windows (64 bit) using declares. Luckily, Xojo had a blog entry on exactly this topic: https://blog.xojo.com/2014/09/15/using-declares-in-your-multi-platform-desktop-apps/

While it works well when building my app as 32-bit app, it makes a completely invisible window on 64-bit apps and I have no idea why this happens.

Simple app: Just a button that contains an action event and this code from example:

Declare Sub setAlphaValue Lib "Cocoa" selector "setAlphaValue:" (windowRef As Integer, windowAlpha As Single) setAlphaValue(Self.Handle, 0.5) //Here self refers to our Xojo Window instance

Any help is highly appreciated. Perhaps it’s time to update the blog entry for 64-bit systems…

Carsten :slight_smile:

It looks like the CGFloat type is 4 bytes on 32-bit and 8 bytes on 64 bit, but a Xojo Single is always 4 bytes. Try changing the windowAlpha As Single parameter into windowAlpha As Double for 64-bit builds.

On macOS you can use CGFloat This is a Single for 32-bit builds, Double for 64-bit builds…

Hello, and Thanks a lot shao
Works very well with CGFloat. Here is the code for MacOs 32 or 64 bits for semi Transparent Window

Declare Sub setAlphaValue Lib “Cocoa” selector “setAlphaValue:” (windowRef As Integer, windowAlpha As CGFloat)
setAlphaValue(Self.Handle, 0.5) //Here self refers to our Xojo Window instance