Search code examples
windowsapiwinapidwm

How do I freeze a live thumbnail using DWMWA_FREEZE_REPRESENTATION?


I'm successfully projecting another windows' content (in my test case now, notepad) into my own window. It works just fine.

What I don't manage to do is freezing it, as offered by the API using DwmSetWindowAttribute (here) with the parameter DWMWA_FREEZE_REPRESENTATION (here), which equals 15 according to the internet.

dwmSetWindowAttribute(MyWindow,15,@Value,1)

I've tried literally all the variants. Sending 1 byte, sending 4 bytes, value 1, 0, "maxdword" etc. etc. The return value is always -2147024809, which - unless i get that wrong - means "Invalid Parameter".

Using a workaround by grabbing the DC of the window I am projecting isn't an option due to the slowness of BitBlt. I've stumbled across dwm thumbnails after looking for reasonably quickly implementable alternatives.

Searching the internet for DWMWA_FREEZE_REPRESENTATION does not yield me anything useful at all, as if no one else even tries using it. I guess my question will soon be the number one search result on google.

Running on Windows 10's May update.

How can I get this to work?


Solution

  • The 3rd and 4th parameters are really BOOL* and sizeof(BOOL), but the 1st needs to be a UWP window. DWMWA_FREEZE_REPRESENTATION is only available for UWP windows which is not metioned in document.