Vibrancy Windows on Windows

Julian ones provided the below code to have vibrancy windows on Windows.
This code only seems to work when you compile to 32bit. It doesn’t when compiling to 64bit.

Two questions:

  • How to get this to work for 64bit?
  • How can we do this vibrancy only on a part of the window (so not the full window)?

Self.BackgroundColor = &c00000000 'use black so it looks “ok”, not sure alpha is implemented in the framework here
Self.HasBackgroundColor = True


Dim mb As New MemoryBlock(AccentPolicy.Size)
Dim p As Ptr = mb
p.AccentPolicy.AccentState = ACCENT_ENABLE_BLURBEHIND 'ACCENT_DISABLED to disable blur

Dim ad As AttrData
ad.Attribute = WCA_ACCENT_POLICY
ad.DataBuffer = p
ad.nSize = mb.Size

Declare Function SetWindowCompositionAttribute Lib “User32.Dll” (hwnd As Integer, ByRef AttrDate As AttrData) As Int32

Dim r As Int32 = SetWindowCompositionAttribute(Self.Handle, ad)

What I actaully want to achieve is making my app look more or less modern.
For example making a part of the GUI vibrant like this:

That’s interesting. I’ve no solution for this, but this could be interesting for @Xojo (@Greg_O_Lone) to make the Navigator and Project Window on also translucent on Windows like it is for years in macOS to make the IDE more consistent.
Maybe they can add on optional property to Window/ContainerControl/Canvas for us users. What do you think @Greg_O_Lone?

It‘s maybe because of Dim r As Int32? Maybe it has to be Int64 or better Integer?

No, I already tried that. :slight_smile:

It would be great if we could do this for the Canvas control. On macOS this is already possible with declares.
For sure it would make Windows app look modern.


Maybe this will help you figure it out:

1 Like

Looks interesting. If someone could convert that Delhpi code to Xojo would be great. :slight_smile:

For AttrData check the alignment.

The ptr is 8 byte in 64-bit for sure.
Not sure if C compiler aligns it to 8 byte for this structure as I can’t find it’s definition. But you could try with various settings.

@ChristopheDV, have you had any successes in the meantime that you can share with us?

Nope … doesn’t work on 64bit.
And on 32bit I can only get it to work on a full window. I need just a part of it to be vibrancy.

I don’t think it’s possible with the Xojo Framework. Proof me wrong, though :wink:

Too bad, that would really enhance Windows Apps visually.

I think Christian can add this for the MBP plugins. Not sure if he wants to put time into this. :slight_smile: