Simnico99 / MicaWPF

This is a library to make Mica available in WPF.
MIT License
207 stars 11 forks source link

Don't work anymore on the last Insider Build #1

Closed gaetandezeiraud closed 2 years ago

gaetandezeiraud commented 2 years ago

Microsoft has disabled the trick to apply Mica with dwmapi. In the last Insider Build. Only solution now seems to recreate it like https://github.com/ad2017gd/Mica32.

Simnico99 commented 2 years ago

Yep I am looking into doing something like that.

I will do some experiment this weekend I will get back to you when I figure out how to replicate what they do in C# or just wrap my code arround it.

gaetandezeiraud commented 2 years ago

I have done an implementation. But Airspace Issue, a crazy thing. For the moment I have abandoned. If you want here the code. WPF is render behind the compositor. I don't find a solution.

Two exist but not very good:

  1. Overlapping Windows: You can create multiple WPF windows one for rendereing the WPF Content and one for Acrylic Effect, These windows should be transparent and must communicate with each other to sync the window resize, window drag and other events, this is possible by overriding WndProc. But this method will cause Flickerng on resize and also affects the Acrylic Effect during maximize animation. (This has been tested before)

  2. WPF Swapchain Hack: This is another possible way that i haven't tested yet, but theoretically it might be working. This can be done by hacking into WPF Swapchain to obtain its back buffer and copy it into an ID2D1Bitmap or similar and then passing it to the Windows.UI.Composition.Visual by using somethng like Composition Native Interoperation. By this way we may be able to overcome the Airspace Issue with WPF Acrylic Effect. (😅 The truth is Currently i was only able to get the swapchain backbuffer from WPF)

  3. Convert the composer Sprite to a Win2D buffer, to convert it to a WPF bitmapImage or similar. But I am stuck at the first step.

Here the code if you want InteropCompositor-master.zip

gaetandezeiraud commented 2 years ago

GDI+ solution can also work. But some problem with the current implementation for the moment (with multiple monitor) https://github.com/ad2017gd/Mica32/issues/3

But don't know if it is possible to pass the hwnd of WPF to a C++ dll. I think yes in theory.

Simnico99 commented 2 years ago

Well, I've worked on a wrapper for Mica32 it actually works I've been able to pass the HWND of the WPF window. It does work but my only issues right now is that it makes a rectangle that delete the controls in the Window. I'd be trying to modify that to return a brush or something, We will see.

If you wanna take a look I've pushed a branch with the Mica32 and Mica32Wrapper: https://github.com/Simnico99/MicaWPF/tree/Mica32-dev-test

Simnico99 commented 2 years ago

Thx to Difegue I've been able to make Mica work in the last Preview update: https://github.com/Difegue/TVC-16

gaetandezeiraud commented 2 years ago

Yeah official API now available.